{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ae0550aa",
   "metadata": {},
   "source": [
    "# week2的作业＋python课程每个周所有的笔记"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8878e7c2",
   "metadata": {},
   "source": [
    "### 调用datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "80ac202a",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8894d1d9",
   "metadata": {},
   "source": [
    "##### 前一个datetime是要从中导入可重用代码的标准库模块的名字；后一个datetime是子模块的名字。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "80b3aa60",
   "metadata": {},
   "outputs": [],
   "source": [
    "odds = [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59 ]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "562813b0",
   "metadata": {},
   "source": [
    "#### python中一行结束就标志着一条语句结束  \n",
    "#### 这个列表已经存在，而且已经赋给odds变量（通过使用赋值操作符=），它包含所示的这些数字。\n",
    "\n",
    "###### ①python中的列表也用中括号（[]）表示；②python中的列表可以包含任意类型的数据，甚至可以在一个列表中混合不同的数据类型 ②odds是一个整数列表，注意：这个odds列表跨三行，尽管这只是一条语句"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "427b22b1",
   "metadata": {},
   "outputs": [],
   "source": [
    "right_this_minute =datetime.today().minute"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "153e879e",
   "metadata": {},
   "source": [
    "#####  （）这里调用一个值，这个值将赋给一个变量。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "f9b3bc5d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a972c774",
   "metadata": {},
   "source": [
    "##### 这个“if”语句结果为“True\"或“False\".\n",
    "##### \"in\"操作符非常强大，它能确定一个对象是不是在另一个对象里。in操作符会返回True或False.\n",
    "##### \"print\"函数会在标准输出上（也就是你的屏幕）显示一个消息。\n",
    "##### 代码组可以包含嵌套代码组\n",
    "##### 冒号引入一个缩进的代码组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "13dcb480",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f01ff7c9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "59ff9cbf",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cf0fc250",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "a2202097",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a201b92",
   "metadata": {},
   "source": [
    "##### 并不是一定要把imports放在代码最上面，但是对python程序员来说，这是一个约定俗成的做法。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "04780fab",
   "metadata": {},
   "outputs": [],
   "source": [
    "odds = [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "39bc1224",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n",
      "Not an odd minute.\n",
      "Not an odd minute.\n",
      "Not an odd minute.\n",
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    right_this_minute =datetime.today().minute\n",
    "    if right_this_minute in odds:\n",
    "        print(\"This minute seems a little odd.\")\n",
    "    else:\n",
    "        print(\"Not an odd minute.\")\n",
    "    wait_time = random.randint(1,60)\n",
    "    time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "be4cd6d9",
   "metadata": {},
   "source": [
    "##### for循环准确地迭代5次。for循环可以用来迭代固定次数，如果能提前知道需要循环多少次就可以使用for。for循环可以迭代处理任意的序列（如列表或字符串），也可以执行固定的次数（利用range函数）\n",
    "#####  random模块有一个非常有用的函数，名为randint，它会生成指定范围内的一个随机整数。\n",
    "##### 如果需要让程序的执行暂停指定的秒数，可以使用标准库time模块提供的sleep函数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "7a1dcea8",
   "metadata": {},
   "outputs": [],
   "source": [
    "word = \"bottles\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aece76e0",
   "metadata": {},
   "source": [
    "##### 将值“bottles”（一个字符串）赋给一个名为“word”的新变量。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "8827347e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles of beer on the wall.\n",
      "99 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "98 bottles of beer on the wall.\n",
      "\n",
      "98 bottles of beer on the wall.\n",
      "98 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "97 bottles of beer on the wall.\n",
      "\n",
      "97 bottles of beer on the wall.\n",
      "97 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "96 bottles of beer on the wall.\n",
      "\n",
      "96 bottles of beer on the wall.\n",
      "96 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "95 bottles of beer on the wall.\n",
      "\n",
      "95 bottles of beer on the wall.\n",
      "95 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "94 bottles of beer on the wall.\n",
      "\n",
      "94 bottles of beer on the wall.\n",
      "94 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "93 bottles of beer on the wall.\n",
      "\n",
      "93 bottles of beer on the wall.\n",
      "93 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "92 bottles of beer on the wall.\n",
      "\n",
      "92 bottles of beer on the wall.\n",
      "92 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "91 bottles of beer on the wall.\n",
      "\n",
      "91 bottles of beer on the wall.\n",
      "91 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "90 bottles of beer on the wall.\n",
      "\n",
      "90 bottles of beer on the wall.\n",
      "90 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "89 bottles of beer on the wall.\n",
      "\n",
      "89 bottles of beer on the wall.\n",
      "89 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "88 bottles of beer on the wall.\n",
      "\n",
      "88 bottles of beer on the wall.\n",
      "88 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "87 bottles of beer on the wall.\n",
      "\n",
      "87 bottles of beer on the wall.\n",
      "87 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "86 bottles of beer on the wall.\n",
      "\n",
      "86 bottles of beer on the wall.\n",
      "86 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "85 bottles of beer on the wall.\n",
      "\n",
      "85 bottles of beer on the wall.\n",
      "85 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "84 bottles of beer on the wall.\n",
      "\n",
      "84 bottles of beer on the wall.\n",
      "84 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "83 bottles of beer on the wall.\n",
      "\n",
      "83 bottles of beer on the wall.\n",
      "83 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "82 bottles of beer on the wall.\n",
      "\n",
      "82 bottles of beer on the wall.\n",
      "82 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "81 bottles of beer on the wall.\n",
      "\n",
      "81 bottles of beer on the wall.\n",
      "81 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "80 bottles of beer on the wall.\n",
      "\n",
      "80 bottles of beer on the wall.\n",
      "80 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "79 bottles of beer on the wall.\n",
      "\n",
      "79 bottles of beer on the wall.\n",
      "79 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "78 bottles of beer on the wall.\n",
      "\n",
      "78 bottles of beer on the wall.\n",
      "78 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "77 bottles of beer on the wall.\n",
      "\n",
      "77 bottles of beer on the wall.\n",
      "77 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "76 bottles of beer on the wall.\n",
      "\n",
      "76 bottles of beer on the wall.\n",
      "76 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "75 bottles of beer on the wall.\n",
      "\n",
      "75 bottles of beer on the wall.\n",
      "75 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "74 bottles of beer on the wall.\n",
      "\n",
      "74 bottles of beer on the wall.\n",
      "74 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "73 bottles of beer on the wall.\n",
      "\n",
      "73 bottles of beer on the wall.\n",
      "73 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "72 bottles of beer on the wall.\n",
      "\n",
      "72 bottles of beer on the wall.\n",
      "72 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "71 bottles of beer on the wall.\n",
      "\n",
      "71 bottles of beer on the wall.\n",
      "71 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "70 bottles of beer on the wall.\n",
      "\n",
      "70 bottles of beer on the wall.\n",
      "70 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "69 bottles of beer on the wall.\n",
      "\n",
      "69 bottles of beer on the wall.\n",
      "69 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "68 bottles of beer on the wall.\n",
      "\n",
      "68 bottles of beer on the wall.\n",
      "68 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "67 bottles of beer on the wall.\n",
      "\n",
      "67 bottles of beer on the wall.\n",
      "67 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "66 bottles of beer on the wall.\n",
      "\n",
      "66 bottles of beer on the wall.\n",
      "66 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "65 bottles of beer on the wall.\n",
      "\n",
      "65 bottles of beer on the wall.\n",
      "65 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "64 bottles of beer on the wall.\n",
      "\n",
      "64 bottles of beer on the wall.\n",
      "64 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "63 bottles of beer on the wall.\n",
      "\n",
      "63 bottles of beer on the wall.\n",
      "63 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "62 bottles of beer on the wall.\n",
      "\n",
      "62 bottles of beer on the wall.\n",
      "62 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "61 bottles of beer on the wall.\n",
      "\n",
      "61 bottles of beer on the wall.\n",
      "61 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "60 bottles of beer on the wall.\n",
      "\n",
      "60 bottles of beer on the wall.\n",
      "60 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "59 bottles of beer on the wall.\n",
      "\n",
      "59 bottles of beer on the wall.\n",
      "59 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "58 bottles of beer on the wall.\n",
      "\n",
      "58 bottles of beer on the wall.\n",
      "58 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "57 bottles of beer on the wall.\n",
      "\n",
      "57 bottles of beer on the wall.\n",
      "57 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "56 bottles of beer on the wall.\n",
      "\n",
      "56 bottles of beer on the wall.\n",
      "56 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "55 bottles of beer on the wall.\n",
      "\n",
      "55 bottles of beer on the wall.\n",
      "55 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "54 bottles of beer on the wall.\n",
      "\n",
      "54 bottles of beer on the wall.\n",
      "54 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "53 bottles of beer on the wall.\n",
      "\n",
      "53 bottles of beer on the wall.\n",
      "53 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "52 bottles of beer on the wall.\n",
      "\n",
      "52 bottles of beer on the wall.\n",
      "52 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "51 bottles of beer on the wall.\n",
      "\n",
      "51 bottles of beer on the wall.\n",
      "51 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "50 bottles of beer on the wall.\n",
      "\n",
      "50 bottles of beer on the wall.\n",
      "50 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "49 bottles of beer on the wall.\n",
      "\n",
      "49 bottles of beer on the wall.\n",
      "49 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "48 bottles of beer on the wall.\n",
      "\n",
      "48 bottles of beer on the wall.\n",
      "48 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "47 bottles of beer on the wall.\n",
      "\n",
      "47 bottles of beer on the wall.\n",
      "47 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "46 bottles of beer on the wall.\n",
      "\n",
      "46 bottles of beer on the wall.\n",
      "46 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "45 bottles of beer on the wall.\n",
      "\n",
      "45 bottles of beer on the wall.\n",
      "45 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "44 bottles of beer on the wall.\n",
      "\n",
      "44 bottles of beer on the wall.\n",
      "44 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "43 bottles of beer on the wall.\n",
      "\n",
      "43 bottles of beer on the wall.\n",
      "43 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "42 bottles of beer on the wall.\n",
      "\n",
      "42 bottles of beer on the wall.\n",
      "42 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "41 bottles of beer on the wall.\n",
      "\n",
      "41 bottles of beer on the wall.\n",
      "41 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "40 bottles of beer on the wall.\n",
      "\n",
      "40 bottles of beer on the wall.\n",
      "40 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "39 bottles of beer on the wall.\n",
      "\n",
      "39 bottles of beer on the wall.\n",
      "39 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "38 bottles of beer on the wall.\n",
      "\n",
      "38 bottles of beer on the wall.\n",
      "38 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "37 bottles of beer on the wall.\n",
      "\n",
      "37 bottles of beer on the wall.\n",
      "37 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "36 bottles of beer on the wall.\n",
      "\n",
      "36 bottles of beer on the wall.\n",
      "36 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "35 bottles of beer on the wall.\n",
      "\n",
      "35 bottles of beer on the wall.\n",
      "35 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "34 bottles of beer on the wall.\n",
      "\n",
      "34 bottles of beer on the wall.\n",
      "34 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "33 bottles of beer on the wall.\n",
      "\n",
      "33 bottles of beer on the wall.\n",
      "33 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "32 bottles of beer on the wall.\n",
      "\n",
      "32 bottles of beer on the wall.\n",
      "32 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "31 bottles of beer on the wall.\n",
      "\n",
      "31 bottles of beer on the wall.\n",
      "31 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "30 bottles of beer on the wall.\n",
      "\n",
      "30 bottles of beer on the wall.\n",
      "30 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "29 bottles of beer on the wall.\n",
      "\n",
      "29 bottles of beer on the wall.\n",
      "29 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "28 bottles of beer on the wall.\n",
      "\n",
      "28 bottles of beer on the wall.\n",
      "28 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "27 bottles of beer on the wall.\n",
      "\n",
      "27 bottles of beer on the wall.\n",
      "27 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "26 bottles of beer on the wall.\n",
      "\n",
      "26 bottles of beer on the wall.\n",
      "26 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "25 bottles of beer on the wall.\n",
      "\n",
      "25 bottles of beer on the wall.\n",
      "25 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "24 bottles of beer on the wall.\n",
      "\n",
      "24 bottles of beer on the wall.\n",
      "24 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "23 bottles of beer on the wall.\n",
      "\n",
      "23 bottles of beer on the wall.\n",
      "23 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "22 bottles of beer on the wall.\n",
      "\n",
      "22 bottles of beer on the wall.\n",
      "22 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "21 bottles of beer on the wall.\n",
      "\n",
      "21 bottles of beer on the wall.\n",
      "21 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "20 bottles of beer on the wall.\n",
      "\n",
      "20 bottles of beer on the wall.\n",
      "20 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "19 bottles of beer on the wall.\n",
      "\n",
      "19 bottles of beer on the wall.\n",
      "19 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "18 bottles of beer on the wall.\n",
      "\n",
      "18 bottles of beer on the wall.\n",
      "18 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "17 bottles of beer on the wall.\n",
      "\n",
      "17 bottles of beer on the wall.\n",
      "17 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "16 bottles of beer on the wall.\n",
      "\n",
      "16 bottles of beer on the wall.\n",
      "16 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "15 bottles of beer on the wall.\n",
      "\n",
      "15 bottles of beer on the wall.\n",
      "15 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "14 bottles of beer on the wall.\n",
      "\n",
      "14 bottles of beer on the wall.\n",
      "14 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "13 bottles of beer on the wall.\n",
      "\n",
      "13 bottles of beer on the wall.\n",
      "13 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "12 bottles of beer on the wall.\n",
      "\n",
      "12 bottles of beer on the wall.\n",
      "12 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "11 bottles of beer on the wall.\n",
      "\n",
      "11 bottles of beer on the wall.\n",
      "11 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "10 bottles of beer on the wall.\n",
      "\n",
      "10 bottles of beer on the wall.\n",
      "10 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "9 bottles of beer on the wall.\n",
      "\n",
      "9 bottles of beer on the wall.\n",
      "9 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "8 bottles of beer on the wall.\n",
      "\n",
      "8 bottles of beer on the wall.\n",
      "8 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "7 bottles of beer on the wall.\n",
      "\n",
      "7 bottles of beer on the wall.\n",
      "7 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "6 bottles of beer on the wall.\n",
      "\n",
      "6 bottles of beer on the wall.\n",
      "6 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "5 bottles of beer on the wall.\n",
      "\n",
      "5 bottles of beer on the wall.\n",
      "5 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "4 bottles of beer on the wall.\n",
      "\n",
      "4 bottles of beer on the wall.\n",
      "4 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "3 bottles of beer on the wall.\n",
      "\n",
      "3 bottles of beer on the wall.\n",
      "3 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "2 bottles of beer on the wall.\n",
      "\n",
      "2 bottles of beer on the wall.\n",
      "2 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "1 bottle of beer on the wall.\n",
      "\n",
      "1 bottle of beer on the wall.\n",
      "1 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "No more bottles of beer on the wall.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for beer_num in range(99, 0, -1):\n",
    "    print(beer_num, word, \"of beer on the wall.\")\n",
    "    print(beer_num,word,\"of beer.\")\n",
    "    print(\"Take one down.\")\n",
    "    print(\"Pass it around.\")\n",
    "    if beer_num == 1:\n",
    "        print(\"No more bottles of beer on the wall.\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num,word, \"of beer on the wall.\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c5b80ec7",
   "metadata": {},
   "source": [
    "##### 将值“bottles”（一个字符串）赋给一个名为“word”的新变量。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "714afa22",
   "metadata": {},
   "source": [
    "##### 这里的range循环指定的次数，从99倒数到0.使用“beer_num\"作为循环迭代变量。\n",
    "##### 这里\"range\"调用有3个参数，而不是1个。“range”的调用有3个参数：开始(start)、结束(stop)和步长(step)。\n",
    "> 不只是会在range中遇到start，stop和step，下面介绍一下它们是什么意思\n",
    ">> START值允许你控制范围从哪里开始\n",
    "到目前为止，我们一直在用只有一个参数的range版本，根据文档，这需要指定一个范围结束值。如果没有提供其他值，range就默认使用0作为开始值，不过也可以把它设置为你选择的某个值。如果设置了开始值，就必须再提供一个结束值。这样一来，range就会成为一个多参数调用。\n",
    ">> STOP允许你控制范围何时结束。\n",
    "我们的代码中调用range（5）时就使用了这个参数。注意，生成的范围并不包含这个结束值，所以这个结束值是一个上限，但不包含在范围内。\n",
    ">> STEP值允许你控制如何生成范围。\n",
    "指定开始和结束值时，还可以（可选）指定一个步长值。默认地，步长值为1，这会告诉range按1个步长生成各个值，也就是说，0，1，2，3，4，依此类推。可以把step设置为任何值来调整步长。还可以将step设置为一个负值来调整所生成的范围的方向。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ab899a5b",
   "metadata": {},
   "source": [
    "##### 这四个print函数调用显示当前迭代的歌词，“99 bottles of beer on the wall.99 bottles of beer.Take one down.Pass it around.”，每次迭代时类推。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3d74e3d",
   "metadata": {},
   "source": [
    "##### print输出完整结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6d1c1518",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cdb1bae8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ec75e4dc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "58b107a3",
   "metadata": {},
   "source": [
    "###  我的很多很多笔记"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d4526cbb",
   "metadata": {},
   "source": [
    "1.jupyter notebook 扩展与插件\n",
    "插件安装教程\n",
    "jupyter notebook 快捷键介绍 详情在jupyter notebook 的菜单栏中的 Help 键盘快捷键栏中查看\n",
    "进入命令模式之后（此时没有活跃的单元格），以下快捷键将会有帮助：\n",
    "A会在活跃单元之上插入一个新的单元，B会在活跃单元之下插入一个新单元。\n",
    "连续按两次D，可以删除一个单元格。\n",
    "撤销被删除的单元，按Z。\n",
    "Y会将当前活跃的单元变成一个代码单元。\n",
    "按F会弹出【查找和替换】菜单。\n",
    "按住Shift+上或下箭头可以选择多个单元。在多选模式下，按住Shift+M可以合并你的选择。\n",
    "处于编辑模式时（在命令模式时按Enter会进入编辑模式），以下快捷键将会有帮助：\n",
    "Ctrl+Home 到达单元起始位置。\n",
    "Ctrl+S保存进度。\n",
    "Ctrl+Enter 会运行整个单元块。\n",
    "Alt+Enter 不止会运行你的单元块，还会在下面添加一个新单元。\n",
    "2.深入对python的数值和字符串的了解与掌握\n",
    "* 数值学习文档在https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex\n",
    "* 字符串学习文档在https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str\n",
    "3.常见模块的使用\n",
    "datetime\n",
    "time\n",
    "help()\n",
    "range 函数的使用\n",
    "random 模块的使用\n",
    "datetime 和time 以及注意事项\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9af680c1",
   "metadata": {},
   "source": [
    "* jupyter notebook 的运行代码注意事项\n",
    "* 代码运行是有顺序的，一定要注意前后代码块的运行先后。\n",
    "* 一定要先运行含有模块的单元，再进行后续的模块中所含有的方法的单元。\n",
    "* 模块和方法可以在不同的代码块中。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e4fa0d89",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 调用模块\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "106ea594",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2021, 10, 8)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# datetime 里面的date方法\n",
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "c7ae31f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# datetime 里面的date方法取出年月日\n",
    "datetime.date.today().day #同理 年 月"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "668b1006",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2021, 10, 8, 8, 55, 59, 483037)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#datetime 里面的datetime的方法 可以取出年 月 日 时 分 秒 毫秒 微秒\n",
    "datetime.datetime.today()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "e0977ea7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-10-08'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# datetime中 isoformat 格式化年月日\n",
    "datetime.date.isoformat(datetime.date.today())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "4e6be372",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on module datetime:\n",
      "\n",
      "NAME\n",
      "    datetime - Fast implementation of the datetime type.\n",
      "\n",
      "MODULE REFERENCE\n",
      "    https://docs.python.org/3.8/library/datetime\n",
      "    \n",
      "    The following documentation is automatically generated from the Python\n",
      "    source files.  It may be incomplete, incorrect or include features that\n",
      "    are considered implementation detail and may vary between Python\n",
      "    implementations.  When in doubt, consult the module reference at the\n",
      "    location listed above.\n",
      "\n",
      "CLASSES\n",
      "    builtins.object\n",
      "        date\n",
      "            datetime\n",
      "        time\n",
      "        timedelta\n",
      "        tzinfo\n",
      "            timezone\n",
      "    \n",
      "    class date(builtins.object)\n",
      "     |  date(year, month, day) --> date object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __add__(self, value, /)\n",
      "     |      Return self+value.\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __format__(...)\n",
      "     |      Formats self with strftime.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __radd__(self, value, /)\n",
      "     |      Return value+self.\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      __reduce__() -> (cls, state)\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  __rsub__(self, value, /)\n",
      "     |      Return value-self.\n",
      "     |  \n",
      "     |  __str__(self, /)\n",
      "     |      Return str(self).\n",
      "     |  \n",
      "     |  __sub__(self, value, /)\n",
      "     |      Return self-value.\n",
      "     |  \n",
      "     |  ctime(...)\n",
      "     |      Return ctime() style string.\n",
      "     |  \n",
      "     |  isocalendar(...)\n",
      "     |      Return a 3-tuple containing ISO year, week number, and weekday.\n",
      "     |  \n",
      "     |  isoformat(...)\n",
      "     |      Return string in ISO 8601 format, YYYY-MM-DD.\n",
      "     |  \n",
      "     |  isoweekday(...)\n",
      "     |      Return the day of the week represented by the date.\n",
      "     |      Monday == 1 ... Sunday == 7\n",
      "     |  \n",
      "     |  replace(...)\n",
      "     |      Return date with new specified fields.\n",
      "     |  \n",
      "     |  strftime(...)\n",
      "     |      format -> strftime() style string.\n",
      "     |  \n",
      "     |  timetuple(...)\n",
      "     |      Return time tuple, compatible with time.localtime().\n",
      "     |  \n",
      "     |  toordinal(...)\n",
      "     |      Return proleptic Gregorian ordinal.  January 1 of year 1 is day 1.\n",
      "     |  \n",
      "     |  weekday(...)\n",
      "     |      Return the day of the week represented by the date.\n",
      "     |      Monday == 0 ... Sunday == 6\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods defined here:\n",
      "     |  \n",
      "     |  fromisocalendar(...) from builtins.type\n",
      "     |      int, int, int -> Construct a date from the ISO year, week number and weekday.\n",
      "     |      \n",
      "     |      This is the inverse of the date.isocalendar() function\n",
      "     |  \n",
      "     |  fromisoformat(...) from builtins.type\n",
      "     |      str -> Construct a date from the output of date.isoformat()\n",
      "     |  \n",
      "     |  fromordinal(...) from builtins.type\n",
      "     |      int -> date corresponding to a proleptic Gregorian ordinal.\n",
      "     |  \n",
      "     |  fromtimestamp(timestamp, /) from builtins.type\n",
      "     |      Create a date from a POSIX timestamp.\n",
      "     |      \n",
      "     |      The timestamp is a number, e.g. created via time.time(), that is interpreted\n",
      "     |      as local time.\n",
      "     |  \n",
      "     |  today(...) from builtins.type\n",
      "     |      Current date or datetime:  same as self.__class__.fromtimestamp(time.time()).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  day\n",
      "     |  \n",
      "     |  month\n",
      "     |  \n",
      "     |  year\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  max = datetime.date(9999, 12, 31)\n",
      "     |  \n",
      "     |  min = datetime.date(1, 1, 1)\n",
      "     |  \n",
      "     |  resolution = datetime.timedelta(days=1)\n",
      "    \n",
      "    class datetime(date)\n",
      "     |  datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])\n",
      "     |  \n",
      "     |  The year, month and day arguments are required. tzinfo may be None, or an\n",
      "     |  instance of a tzinfo subclass. The remaining arguments may be ints.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      datetime\n",
      "     |      date\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __add__(self, value, /)\n",
      "     |      Return self+value.\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __radd__(self, value, /)\n",
      "     |      Return value+self.\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      __reduce__() -> (cls, state)\n",
      "     |  \n",
      "     |  __reduce_ex__(...)\n",
      "     |      __reduce_ex__(proto) -> (cls, state)\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  __rsub__(self, value, /)\n",
      "     |      Return value-self.\n",
      "     |  \n",
      "     |  __str__(self, /)\n",
      "     |      Return str(self).\n",
      "     |  \n",
      "     |  __sub__(self, value, /)\n",
      "     |      Return self-value.\n",
      "     |  \n",
      "     |  astimezone(...)\n",
      "     |      tz -> convert to local time in new timezone tz\n",
      "     |  \n",
      "     |  ctime(...)\n",
      "     |      Return ctime() style string.\n",
      "     |  \n",
      "     |  date(...)\n",
      "     |      Return date object with same year, month and day.\n",
      "     |  \n",
      "     |  dst(...)\n",
      "     |      Return self.tzinfo.dst(self).\n",
      "     |  \n",
      "     |  isoformat(...)\n",
      "     |      [sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM].\n",
      "     |      sep is used to separate the year from the time, and defaults to 'T'.\n",
      "     |      The optional argument timespec specifies the number of additional terms\n",
      "     |      of the time to include. Valid options are 'auto', 'hours', 'minutes',\n",
      "     |      'seconds', 'milliseconds' and 'microseconds'.\n",
      "     |  \n",
      "     |  replace(...)\n",
      "     |      Return datetime with new specified fields.\n",
      "     |  \n",
      "     |  time(...)\n",
      "     |      Return time object with same time but with tzinfo=None.\n",
      "     |  \n",
      "     |  timestamp(...)\n",
      "     |      Return POSIX timestamp as float.\n",
      "     |  \n",
      "     |  timetuple(...)\n",
      "     |      Return time tuple, compatible with time.localtime().\n",
      "     |  \n",
      "     |  timetz(...)\n",
      "     |      Return time object with same time and tzinfo.\n",
      "     |  \n",
      "     |  tzname(...)\n",
      "     |      Return self.tzinfo.tzname(self).\n",
      "     |  \n",
      "     |  utcoffset(...)\n",
      "     |      Return self.tzinfo.utcoffset(self).\n",
      "     |  \n",
      "     |  utctimetuple(...)\n",
      "     |      Return UTC time tuple, compatible with time.localtime().\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods defined here:\n",
      "     |  \n",
      "     |  combine(...) from builtins.type\n",
      "     |      date, time -> datetime with same date and time fields\n",
      "     |  \n",
      "     |  fromisoformat(...) from builtins.type\n",
      "     |      string -> datetime from datetime.isoformat() output\n",
      "     |  \n",
      "     |  fromtimestamp(...) from builtins.type\n",
      "     |      timestamp[, tz] -> tz's local time from POSIX timestamp.\n",
      "     |  \n",
      "     |  now(tz=None) from builtins.type\n",
      "     |      Returns new datetime object representing current time local to tz.\n",
      "     |      \n",
      "     |        tz\n",
      "     |          Timezone object.\n",
      "     |      \n",
      "     |      If no tz is specified, uses local timezone.\n",
      "     |  \n",
      "     |  strptime(...) from builtins.type\n",
      "     |      string, format -> new datetime parsed from a string (like time.strptime()).\n",
      "     |  \n",
      "     |  utcfromtimestamp(...) from builtins.type\n",
      "     |      Construct a naive UTC datetime from a POSIX timestamp.\n",
      "     |  \n",
      "     |  utcnow(...) from builtins.type\n",
      "     |      Return a new datetime representing UTC day and time.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  fold\n",
      "     |  \n",
      "     |  hour\n",
      "     |  \n",
      "     |  microsecond\n",
      "     |  \n",
      "     |  minute\n",
      "     |  \n",
      "     |  second\n",
      "     |  \n",
      "     |  tzinfo\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  max = datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)\n",
      "     |  \n",
      "     |  min = datetime.datetime(1, 1, 1, 0, 0)\n",
      "     |  \n",
      "     |  resolution = datetime.timedelta(microseconds=1)\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from date:\n",
      "     |  \n",
      "     |  __format__(...)\n",
      "     |      Formats self with strftime.\n",
      "     |  \n",
      "     |  isocalendar(...)\n",
      "     |      Return a 3-tuple containing ISO year, week number, and weekday.\n",
      "     |  \n",
      "     |  isoweekday(...)\n",
      "     |      Return the day of the week represented by the date.\n",
      "     |      Monday == 1 ... Sunday == 7\n",
      "     |  \n",
      "     |  strftime(...)\n",
      "     |      format -> strftime() style string.\n",
      "     |  \n",
      "     |  toordinal(...)\n",
      "     |      Return proleptic Gregorian ordinal.  January 1 of year 1 is day 1.\n",
      "     |  \n",
      "     |  weekday(...)\n",
      "     |      Return the day of the week represented by the date.\n",
      "     |      Monday == 0 ... Sunday == 6\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods inherited from date:\n",
      "     |  \n",
      "     |  fromisocalendar(...) from builtins.type\n",
      "     |      int, int, int -> Construct a date from the ISO year, week number and weekday.\n",
      "     |      \n",
      "     |      This is the inverse of the date.isocalendar() function\n",
      "     |  \n",
      "     |  fromordinal(...) from builtins.type\n",
      "     |      int -> date corresponding to a proleptic Gregorian ordinal.\n",
      "     |  \n",
      "     |  today(...) from builtins.type\n",
      "     |      Current date or datetime:  same as self.__class__.fromtimestamp(time.time()).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors inherited from date:\n",
      "     |  \n",
      "     |  day\n",
      "     |  \n",
      "     |  month\n",
      "     |  \n",
      "     |  year\n",
      "    \n",
      "    class time(builtins.object)\n",
      "     |  time([hour[, minute[, second[, microsecond[, tzinfo]]]]]) --> a time object\n",
      "     |  \n",
      "     |  All arguments are optional. tzinfo may be None, or an instance of\n",
      "     |  a tzinfo subclass. The remaining arguments may be ints.\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __format__(...)\n",
      "     |      Formats self with strftime.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      __reduce__() -> (cls, state)\n",
      "     |  \n",
      "     |  __reduce_ex__(...)\n",
      "     |      __reduce_ex__(proto) -> (cls, state)\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  __str__(self, /)\n",
      "     |      Return str(self).\n",
      "     |  \n",
      "     |  dst(...)\n",
      "     |      Return self.tzinfo.dst(self).\n",
      "     |  \n",
      "     |  isoformat(...)\n",
      "     |      Return string in ISO 8601 format, [HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM].\n",
      "     |      \n",
      "     |      The optional argument timespec specifies the number of additional terms\n",
      "     |      of the time to include. Valid options are 'auto', 'hours', 'minutes',\n",
      "     |      'seconds', 'milliseconds' and 'microseconds'.\n",
      "     |  \n",
      "     |  replace(...)\n",
      "     |      Return time with new specified fields.\n",
      "     |  \n",
      "     |  strftime(...)\n",
      "     |      format -> strftime() style string.\n",
      "     |  \n",
      "     |  tzname(...)\n",
      "     |      Return self.tzinfo.tzname(self).\n",
      "     |  \n",
      "     |  utcoffset(...)\n",
      "     |      Return self.tzinfo.utcoffset(self).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods defined here:\n",
      "     |  \n",
      "     |  fromisoformat(...) from builtins.type\n",
      "     |      string -> time from time.isoformat() output\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  fold\n",
      "     |  \n",
      "     |  hour\n",
      "     |  \n",
      "     |  microsecond\n",
      "     |  \n",
      "     |  minute\n",
      "     |  \n",
      "     |  second\n",
      "     |  \n",
      "     |  tzinfo\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  max = datetime.time(23, 59, 59, 999999)\n",
      "     |  \n",
      "     |  min = datetime.time(0, 0)\n",
      "     |  \n",
      "     |  resolution = datetime.timedelta(microseconds=1)\n",
      "    \n",
      "    class timedelta(builtins.object)\n",
      "     |  Difference between two datetime values.\n",
      "     |  \n",
      "     |  timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)\n",
      "     |  \n",
      "     |  All arguments are optional and default to 0.\n",
      "     |  Arguments may be integers or floats, and may be positive or negative.\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __abs__(self, /)\n",
      "     |      abs(self)\n",
      "     |  \n",
      "     |  __add__(self, value, /)\n",
      "     |      Return self+value.\n",
      "     |  \n",
      "     |  __bool__(self, /)\n",
      "     |      self != 0\n",
      "     |  \n",
      "     |  __divmod__(self, value, /)\n",
      "     |      Return divmod(self, value).\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __floordiv__(self, value, /)\n",
      "     |      Return self//value.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __mod__(self, value, /)\n",
      "     |      Return self%value.\n",
      "     |  \n",
      "     |  __mul__(self, value, /)\n",
      "     |      Return self*value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __neg__(self, /)\n",
      "     |      -self\n",
      "     |  \n",
      "     |  __pos__(self, /)\n",
      "     |      +self\n",
      "     |  \n",
      "     |  __radd__(self, value, /)\n",
      "     |      Return value+self.\n",
      "     |  \n",
      "     |  __rdivmod__(self, value, /)\n",
      "     |      Return divmod(value, self).\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      __reduce__() -> (cls, state)\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  __rfloordiv__(self, value, /)\n",
      "     |      Return value//self.\n",
      "     |  \n",
      "     |  __rmod__(self, value, /)\n",
      "     |      Return value%self.\n",
      "     |  \n",
      "     |  __rmul__(self, value, /)\n",
      "     |      Return value*self.\n",
      "     |  \n",
      "     |  __rsub__(self, value, /)\n",
      "     |      Return value-self.\n",
      "     |  \n",
      "     |  __rtruediv__(self, value, /)\n",
      "     |      Return value/self.\n",
      "     |  \n",
      "     |  __str__(self, /)\n",
      "     |      Return str(self).\n",
      "     |  \n",
      "     |  __sub__(self, value, /)\n",
      "     |      Return self-value.\n",
      "     |  \n",
      "     |  __truediv__(self, value, /)\n",
      "     |      Return self/value.\n",
      "     |  \n",
      "     |  total_seconds(...)\n",
      "     |      Total seconds in the duration.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  days\n",
      "     |      Number of days.\n",
      "     |  \n",
      "     |  microseconds\n",
      "     |      Number of microseconds (>= 0 and less than 1 second).\n",
      "     |  \n",
      "     |  seconds\n",
      "     |      Number of seconds (>= 0 and less than 1 day).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  max = datetime.timedelta(days=999999999, seconds=86399, microseconds=9...\n",
      "     |  \n",
      "     |  min = datetime.timedelta(days=-999999999)\n",
      "     |  \n",
      "     |  resolution = datetime.timedelta(microseconds=1)\n",
      "    \n",
      "    class timezone(tzinfo)\n",
      "     |  Fixed offset from UTC implementation of tzinfo.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      timezone\n",
      "     |      tzinfo\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getinitargs__(...)\n",
      "     |      pickle support\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  __str__(self, /)\n",
      "     |      Return str(self).\n",
      "     |  \n",
      "     |  dst(...)\n",
      "     |      Return None.\n",
      "     |  \n",
      "     |  fromutc(...)\n",
      "     |      datetime in UTC -> datetime in local time.\n",
      "     |  \n",
      "     |  tzname(...)\n",
      "     |      If name is specified when timezone is created, returns the name.  Otherwise returns offset as 'UTC(+|-)HH:MM'.\n",
      "     |  \n",
      "     |  utcoffset(...)\n",
      "     |      Return fixed offset.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  max = datetime.timezone(datetime.timedelta(seconds=86340))\n",
      "     |  \n",
      "     |  min = datetime.timezone(datetime.timedelta(days=-1, seconds=60))\n",
      "     |  \n",
      "     |  utc = datetime.timezone.utc\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from tzinfo:\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      -> (cls, state)\n",
      "    \n",
      "    class tzinfo(builtins.object)\n",
      "     |  Abstract base class for time zone info objects.\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      -> (cls, state)\n",
      "     |  \n",
      "     |  dst(...)\n",
      "     |      datetime -> DST offset as timedelta positive east of UTC.\n",
      "     |  \n",
      "     |  fromutc(...)\n",
      "     |      datetime in UTC -> datetime in local time.\n",
      "     |  \n",
      "     |  tzname(...)\n",
      "     |      datetime -> string name of time zone.\n",
      "     |  \n",
      "     |  utcoffset(...)\n",
      "     |      datetime -> timedelta showing offset from UTC, negative values indicating West of UTC\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "\n",
      "DATA\n",
      "    MAXYEAR = 9999\n",
      "    MINYEAR = 1\n",
      "    datetime_CAPI = <capsule object \"datetime.datetime_CAPI\">\n",
      "\n",
      "FILE\n",
      "    c:\\program files\\anaconda3\\lib\\datetime.py\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 可以查看datetime 模块中的各种方法的使用\n",
    "help(datetime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "7696d2b6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 调用time 模块\n",
    "import time\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "f29fab3a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in module time:\n",
      "\n",
      "NAME\n",
      "    time - This module provides various functions to manipulate time values.\n",
      "\n",
      "DESCRIPTION\n",
      "    There are two standard representations of time.  One is the number\n",
      "    of seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer\n",
      "    or a floating point number (to represent fractions of seconds).\n",
      "    The Epoch is system-defined; on Unix, it is generally January 1st, 1970.\n",
      "    The actual value can be retrieved by calling gmtime(0).\n",
      "    \n",
      "    The other representation is a tuple of 9 integers giving local time.\n",
      "    The tuple items are:\n",
      "      year (including century, e.g. 1998)\n",
      "      month (1-12)\n",
      "      day (1-31)\n",
      "      hours (0-23)\n",
      "      minutes (0-59)\n",
      "      seconds (0-59)\n",
      "      weekday (0-6, Monday is 0)\n",
      "      Julian day (day in the year, 1-366)\n",
      "      DST (Daylight Savings Time) flag (-1, 0 or 1)\n",
      "    If the DST flag is 0, the time is given in the regular time zone;\n",
      "    if it is 1, the time is given in the DST time zone;\n",
      "    if it is -1, mktime() should guess based on the date and time.\n",
      "\n",
      "CLASSES\n",
      "    builtins.tuple(builtins.object)\n",
      "        struct_time\n",
      "    \n",
      "    class struct_time(builtins.tuple)\n",
      "     |  struct_time(iterable=(), /)\n",
      "     |  \n",
      "     |  The time value as returned by gmtime(), localtime(), and strptime(), and\n",
      "     |  accepted by asctime(), mktime() and strftime().  May be considered as a\n",
      "     |  sequence of 9 integers.\n",
      "     |  \n",
      "     |  Note that several fields' values are not the same as those defined by\n",
      "     |  the C language standard for struct tm.  For example, the value of the\n",
      "     |  field tm_year is the actual year, not year - 1900.  See individual\n",
      "     |  fields' descriptions for details.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      struct_time\n",
      "     |      builtins.tuple\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  tm_gmtoff\n",
      "     |      offset from UTC in seconds\n",
      "     |  \n",
      "     |  tm_hour\n",
      "     |      hours, range [0, 23]\n",
      "     |  \n",
      "     |  tm_isdst\n",
      "     |      1 if summer time is in effect, 0 if not, and -1 if unknown\n",
      "     |  \n",
      "     |  tm_mday\n",
      "     |      day of month, range [1, 31]\n",
      "     |  \n",
      "     |  tm_min\n",
      "     |      minutes, range [0, 59]\n",
      "     |  \n",
      "     |  tm_mon\n",
      "     |      month of year, range [1, 12]\n",
      "     |  \n",
      "     |  tm_sec\n",
      "     |      seconds, range [0, 61])\n",
      "     |  \n",
      "     |  tm_wday\n",
      "     |      day of week, range [0, 6], Monday is 0\n",
      "     |  \n",
      "     |  tm_yday\n",
      "     |      day of year, range [1, 366]\n",
      "     |  \n",
      "     |  tm_year\n",
      "     |      year, for example, 1993\n",
      "     |  \n",
      "     |  tm_zone\n",
      "     |      abbreviation of timezone name\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  n_fields = 11\n",
      "     |  \n",
      "     |  n_sequence_fields = 9\n",
      "     |  \n",
      "     |  n_unnamed_fields = 0\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from builtins.tuple:\n",
      "     |  \n",
      "     |  __add__(self, value, /)\n",
      "     |      Return self+value.\n",
      "     |  \n",
      "     |  __contains__(self, key, /)\n",
      "     |      Return key in self.\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __getitem__(self, key, /)\n",
      "     |      Return self[key].\n",
      "     |  \n",
      "     |  __getnewargs__(self, /)\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __iter__(self, /)\n",
      "     |      Implement iter(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __len__(self, /)\n",
      "     |      Return len(self).\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __mul__(self, value, /)\n",
      "     |      Return self*value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __rmul__(self, value, /)\n",
      "     |      Return value*self.\n",
      "     |  \n",
      "     |  count(self, value, /)\n",
      "     |      Return number of occurrences of value.\n",
      "     |  \n",
      "     |  index(self, value, start=0, stop=9223372036854775807, /)\n",
      "     |      Return first index of value.\n",
      "     |      \n",
      "     |      Raises ValueError if the value is not present.\n",
      "\n",
      "FUNCTIONS\n",
      "    asctime(...)\n",
      "        asctime([tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\n",
      "        When the time tuple is not present, current time as returned by localtime()\n",
      "        is used.\n",
      "    \n",
      "    ctime(...)\n",
      "        ctime(seconds) -> string\n",
      "        \n",
      "        Convert a time in seconds since the Epoch to a string in local time.\n",
      "        This is equivalent to asctime(localtime(seconds)). When the time tuple is\n",
      "        not present, current time as returned by localtime() is used.\n",
      "    \n",
      "    get_clock_info(...)\n",
      "        get_clock_info(name: str) -> dict\n",
      "        \n",
      "        Get information of the specified clock.\n",
      "    \n",
      "    gmtime(...)\n",
      "        gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n",
      "                               tm_sec, tm_wday, tm_yday, tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n",
      "        GMT).  When 'seconds' is not passed in, convert the current time instead.\n",
      "        \n",
      "        If the platform supports the tm_gmtoff and tm_zone, they are available as\n",
      "        attributes only.\n",
      "    \n",
      "    localtime(...)\n",
      "        localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,\n",
      "                                  tm_sec,tm_wday,tm_yday,tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing local time.\n",
      "        When 'seconds' is not passed in, convert the current time instead.\n",
      "    \n",
      "    mktime(...)\n",
      "        mktime(tuple) -> floating point number\n",
      "        \n",
      "        Convert a time tuple in local time to seconds since the Epoch.\n",
      "        Note that mktime(gmtime(0)) will not generally return zero for most\n",
      "        time zones; instead the returned value will either be equal to that\n",
      "        of the timezone or altzone attributes on the time module.\n",
      "    \n",
      "    monotonic(...)\n",
      "        monotonic() -> float\n",
      "        \n",
      "        Monotonic clock, cannot go backward.\n",
      "    \n",
      "    monotonic_ns(...)\n",
      "        monotonic_ns() -> int\n",
      "        \n",
      "        Monotonic clock, cannot go backward, as nanoseconds.\n",
      "    \n",
      "    perf_counter(...)\n",
      "        perf_counter() -> float\n",
      "        \n",
      "        Performance counter for benchmarking.\n",
      "    \n",
      "    perf_counter_ns(...)\n",
      "        perf_counter_ns() -> int\n",
      "        \n",
      "        Performance counter for benchmarking as nanoseconds.\n",
      "    \n",
      "    process_time(...)\n",
      "        process_time() -> float\n",
      "        \n",
      "        Process time for profiling: sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    process_time_ns(...)\n",
      "        process_time() -> int\n",
      "        \n",
      "        Process time for profiling as nanoseconds:\n",
      "        sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    sleep(...)\n",
      "        sleep(seconds)\n",
      "        \n",
      "        Delay execution for a given number of seconds.  The argument may be\n",
      "        a floating point number for subsecond precision.\n",
      "    \n",
      "    strftime(...)\n",
      "        strftime(format[, tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string according to a format specification.\n",
      "        See the library reference manual for formatting codes. When the time tuple\n",
      "        is not present, current time as returned by localtime() is used.\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    strptime(...)\n",
      "        strptime(string, format) -> struct_time\n",
      "        \n",
      "        Parse a string to a time tuple according to a format specification.\n",
      "        See the library reference manual for formatting codes (same as\n",
      "        strftime()).\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    thread_time(...)\n",
      "        thread_time() -> float\n",
      "        \n",
      "        Thread time for profiling: sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    thread_time_ns(...)\n",
      "        thread_time() -> int\n",
      "        \n",
      "        Thread time for profiling as nanoseconds:\n",
      "        sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    time(...)\n",
      "        time() -> floating point number\n",
      "        \n",
      "        Return the current time in seconds since the Epoch.\n",
      "        Fractions of a second may be present if the system clock provides them.\n",
      "    \n",
      "    time_ns(...)\n",
      "        time_ns() -> int\n",
      "        \n",
      "        Return the current time in nanoseconds since the Epoch.\n",
      "\n",
      "DATA\n",
      "    altzone = -32400\n",
      "    daylight = 0\n",
      "    timezone = -28800\n",
      "    tzname = ('中国标准时间', '中国夏令时')\n",
      "\n",
      "FILE\n",
      "    (built-in)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 先查看time 的各种方法使用  其中关于格式化的代码可以在 https://www.cnblogs.com/xuzhichao/p/11407192.html 中查看\n",
    "help(time)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "e534ce66",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=10, tm_mday=8, tm_hour=1, tm_min=3, tm_sec=50, tm_wday=4, tm_yday=281, tm_isdst=0)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 国际标准时间\n",
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "8c07a753",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=10, tm_mday=8, tm_hour=9, tm_min=4, tm_sec=16, tm_wday=4, tm_yday=281, tm_isdst=0)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 本地时间\n",
    "time.localtime()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "84af1125",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'09 : 04'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 格式化时间\n",
    "time.strftime(\"%H : %M\") # 括号里一定要用英文的双引号或者单引号括起来表示字符串。 两个字符串之间可以用任意符号"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "9c6580a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021--10--08'"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#使用time 的 strftime方法找到年月日 然后拼接在一起\n",
    "time.strftime(\"%Y--%m--%d\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "495f02c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'October'"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strftime(\"%B\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "28e4ef4d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Friday'"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strftime(\"%A\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "943ec0e2",
   "metadata": {},
   "source": [
    "#### help的使用方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "3ca0d485",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in module time:\n",
      "\n",
      "NAME\n",
      "    time - This module provides various functions to manipulate time values.\n",
      "\n",
      "DESCRIPTION\n",
      "    There are two standard representations of time.  One is the number\n",
      "    of seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer\n",
      "    or a floating point number (to represent fractions of seconds).\n",
      "    The Epoch is system-defined; on Unix, it is generally January 1st, 1970.\n",
      "    The actual value can be retrieved by calling gmtime(0).\n",
      "    \n",
      "    The other representation is a tuple of 9 integers giving local time.\n",
      "    The tuple items are:\n",
      "      year (including century, e.g. 1998)\n",
      "      month (1-12)\n",
      "      day (1-31)\n",
      "      hours (0-23)\n",
      "      minutes (0-59)\n",
      "      seconds (0-59)\n",
      "      weekday (0-6, Monday is 0)\n",
      "      Julian day (day in the year, 1-366)\n",
      "      DST (Daylight Savings Time) flag (-1, 0 or 1)\n",
      "    If the DST flag is 0, the time is given in the regular time zone;\n",
      "    if it is 1, the time is given in the DST time zone;\n",
      "    if it is -1, mktime() should guess based on the date and time.\n",
      "\n",
      "CLASSES\n",
      "    builtins.tuple(builtins.object)\n",
      "        struct_time\n",
      "    \n",
      "    class struct_time(builtins.tuple)\n",
      "     |  struct_time(iterable=(), /)\n",
      "     |  \n",
      "     |  The time value as returned by gmtime(), localtime(), and strptime(), and\n",
      "     |  accepted by asctime(), mktime() and strftime().  May be considered as a\n",
      "     |  sequence of 9 integers.\n",
      "     |  \n",
      "     |  Note that several fields' values are not the same as those defined by\n",
      "     |  the C language standard for struct tm.  For example, the value of the\n",
      "     |  field tm_year is the actual year, not year - 1900.  See individual\n",
      "     |  fields' descriptions for details.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      struct_time\n",
      "     |      builtins.tuple\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  tm_gmtoff\n",
      "     |      offset from UTC in seconds\n",
      "     |  \n",
      "     |  tm_hour\n",
      "     |      hours, range [0, 23]\n",
      "     |  \n",
      "     |  tm_isdst\n",
      "     |      1 if summer time is in effect, 0 if not, and -1 if unknown\n",
      "     |  \n",
      "     |  tm_mday\n",
      "     |      day of month, range [1, 31]\n",
      "     |  \n",
      "     |  tm_min\n",
      "     |      minutes, range [0, 59]\n",
      "     |  \n",
      "     |  tm_mon\n",
      "     |      month of year, range [1, 12]\n",
      "     |  \n",
      "     |  tm_sec\n",
      "     |      seconds, range [0, 61])\n",
      "     |  \n",
      "     |  tm_wday\n",
      "     |      day of week, range [0, 6], Monday is 0\n",
      "     |  \n",
      "     |  tm_yday\n",
      "     |      day of year, range [1, 366]\n",
      "     |  \n",
      "     |  tm_year\n",
      "     |      year, for example, 1993\n",
      "     |  \n",
      "     |  tm_zone\n",
      "     |      abbreviation of timezone name\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  n_fields = 11\n",
      "     |  \n",
      "     |  n_sequence_fields = 9\n",
      "     |  \n",
      "     |  n_unnamed_fields = 0\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from builtins.tuple:\n",
      "     |  \n",
      "     |  __add__(self, value, /)\n",
      "     |      Return self+value.\n",
      "     |  \n",
      "     |  __contains__(self, key, /)\n",
      "     |      Return key in self.\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __getitem__(self, key, /)\n",
      "     |      Return self[key].\n",
      "     |  \n",
      "     |  __getnewargs__(self, /)\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __iter__(self, /)\n",
      "     |      Implement iter(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __len__(self, /)\n",
      "     |      Return len(self).\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __mul__(self, value, /)\n",
      "     |      Return self*value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __rmul__(self, value, /)\n",
      "     |      Return value*self.\n",
      "     |  \n",
      "     |  count(self, value, /)\n",
      "     |      Return number of occurrences of value.\n",
      "     |  \n",
      "     |  index(self, value, start=0, stop=9223372036854775807, /)\n",
      "     |      Return first index of value.\n",
      "     |      \n",
      "     |      Raises ValueError if the value is not present.\n",
      "\n",
      "FUNCTIONS\n",
      "    asctime(...)\n",
      "        asctime([tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\n",
      "        When the time tuple is not present, current time as returned by localtime()\n",
      "        is used.\n",
      "    \n",
      "    ctime(...)\n",
      "        ctime(seconds) -> string\n",
      "        \n",
      "        Convert a time in seconds since the Epoch to a string in local time.\n",
      "        This is equivalent to asctime(localtime(seconds)). When the time tuple is\n",
      "        not present, current time as returned by localtime() is used.\n",
      "    \n",
      "    get_clock_info(...)\n",
      "        get_clock_info(name: str) -> dict\n",
      "        \n",
      "        Get information of the specified clock.\n",
      "    \n",
      "    gmtime(...)\n",
      "        gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n",
      "                               tm_sec, tm_wday, tm_yday, tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n",
      "        GMT).  When 'seconds' is not passed in, convert the current time instead.\n",
      "        \n",
      "        If the platform supports the tm_gmtoff and tm_zone, they are available as\n",
      "        attributes only.\n",
      "    \n",
      "    localtime(...)\n",
      "        localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,\n",
      "                                  tm_sec,tm_wday,tm_yday,tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing local time.\n",
      "        When 'seconds' is not passed in, convert the current time instead.\n",
      "    \n",
      "    mktime(...)\n",
      "        mktime(tuple) -> floating point number\n",
      "        \n",
      "        Convert a time tuple in local time to seconds since the Epoch.\n",
      "        Note that mktime(gmtime(0)) will not generally return zero for most\n",
      "        time zones; instead the returned value will either be equal to that\n",
      "        of the timezone or altzone attributes on the time module.\n",
      "    \n",
      "    monotonic(...)\n",
      "        monotonic() -> float\n",
      "        \n",
      "        Monotonic clock, cannot go backward.\n",
      "    \n",
      "    monotonic_ns(...)\n",
      "        monotonic_ns() -> int\n",
      "        \n",
      "        Monotonic clock, cannot go backward, as nanoseconds.\n",
      "    \n",
      "    perf_counter(...)\n",
      "        perf_counter() -> float\n",
      "        \n",
      "        Performance counter for benchmarking.\n",
      "    \n",
      "    perf_counter_ns(...)\n",
      "        perf_counter_ns() -> int\n",
      "        \n",
      "        Performance counter for benchmarking as nanoseconds.\n",
      "    \n",
      "    process_time(...)\n",
      "        process_time() -> float\n",
      "        \n",
      "        Process time for profiling: sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    process_time_ns(...)\n",
      "        process_time() -> int\n",
      "        \n",
      "        Process time for profiling as nanoseconds:\n",
      "        sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    sleep(...)\n",
      "        sleep(seconds)\n",
      "        \n",
      "        Delay execution for a given number of seconds.  The argument may be\n",
      "        a floating point number for subsecond precision.\n",
      "    \n",
      "    strftime(...)\n",
      "        strftime(format[, tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string according to a format specification.\n",
      "        See the library reference manual for formatting codes. When the time tuple\n",
      "        is not present, current time as returned by localtime() is used.\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    strptime(...)\n",
      "        strptime(string, format) -> struct_time\n",
      "        \n",
      "        Parse a string to a time tuple according to a format specification.\n",
      "        See the library reference manual for formatting codes (same as\n",
      "        strftime()).\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    thread_time(...)\n",
      "        thread_time() -> float\n",
      "        \n",
      "        Thread time for profiling: sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    thread_time_ns(...)\n",
      "        thread_time() -> int\n",
      "        \n",
      "        Thread time for profiling as nanoseconds:\n",
      "        sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    time(...)\n",
      "        time() -> floating point number\n",
      "        \n",
      "        Return the current time in seconds since the Epoch.\n",
      "        Fractions of a second may be present if the system clock provides them.\n",
      "    \n",
      "    time_ns(...)\n",
      "        time_ns() -> int\n",
      "        \n",
      "        Return the current time in nanoseconds since the Epoch.\n",
      "\n",
      "DATA\n",
      "    altzone = -32400\n",
      "    daylight = 0\n",
      "    timezone = -28800\n",
      "    tzname = ('中国标准时间', '中国夏令时')\n",
      "\n",
      "FILE\n",
      "    (built-in)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#我们可以使用module_name.Tab键 来查看该模块的所有方法，但不能够查看所有方法的细则和使用场景，help可以帮助我们来做这件事\n",
    "#help的使用方法\n",
    "# help(module_name) 接着运行即可查看\n",
    "help(time)  #这个前提是在已经运行过import time 否则就要加上在上方一起运行"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "907c0331",
   "metadata": {},
   "source": [
    "##### range 函数 （范围函数）\n",
    "* 具体使用方法在学习文档\n",
    "* 相关解释与学习在电子版书中的P80"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "471f6635",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):  # i：是特指某个内容（itme）相当于一个变量但是这是个特殊\n",
    "    print(i)        # range(0,5)=range(5)  计算机默认从0开始计数 所以到第5个数字后就结束了 不包含数字5\n",
    "                   # range和for使用 且括号内只有一个数值 表示循环的次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "61bdfc37",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[5, 6, 7, 8, 9]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(5,10))    #range(5,10) 10是指有10个值但是不包含数字10，5是指起始值 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "c321f0a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 3, 6, 9]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(0,10,3))  # 默认步长step为1，也可以自己设置步长值\n",
    "                    # （0，10，3）这里的3表示两个值之间的间隔数，也就是步长值\n",
    "                   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "399e4ee3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[-10, -40, -70]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(-10, -100, -30))     #负数表示方向 对于起始值和结束值和步长值都可以用负数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "e3ac99eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[10, 8, 6, 4, 2]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(10,0,-2))   #这里的-2表示范围的方向"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "355e697e",
   "metadata": {},
   "source": [
    "#### random 函数（随机函数）\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "03ccc2e8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on module random:\n",
      "\n",
      "NAME\n",
      "    random - Random variable generators.\n",
      "\n",
      "MODULE REFERENCE\n",
      "    https://docs.python.org/3.8/library/random\n",
      "    \n",
      "    The following documentation is automatically generated from the Python\n",
      "    source files.  It may be incomplete, incorrect or include features that\n",
      "    are considered implementation detail and may vary between Python\n",
      "    implementations.  When in doubt, consult the module reference at the\n",
      "    location listed above.\n",
      "\n",
      "DESCRIPTION\n",
      "        integers\n",
      "        --------\n",
      "               uniform within range\n",
      "    \n",
      "        sequences\n",
      "        ---------\n",
      "               pick random element\n",
      "               pick random sample\n",
      "               pick weighted random sample\n",
      "               generate random permutation\n",
      "    \n",
      "        distributions on the real line:\n",
      "        ------------------------------\n",
      "               uniform\n",
      "               triangular\n",
      "               normal (Gaussian)\n",
      "               lognormal\n",
      "               negative exponential\n",
      "               gamma\n",
      "               beta\n",
      "               pareto\n",
      "               Weibull\n",
      "    \n",
      "        distributions on the circle (angles 0 to 2pi)\n",
      "        ---------------------------------------------\n",
      "               circular uniform\n",
      "               von Mises\n",
      "    \n",
      "    General notes on the underlying Mersenne Twister core generator:\n",
      "    \n",
      "    * The period is 2**19937-1.\n",
      "    * It is one of the most extensively tested generators in existence.\n",
      "    * The random() method is implemented in C, executes in a single Python step,\n",
      "      and is, therefore, threadsafe.\n",
      "\n",
      "CLASSES\n",
      "    _random.Random(builtins.object)\n",
      "        Random\n",
      "            SystemRandom\n",
      "    \n",
      "    class Random(_random.Random)\n",
      "     |  Random(x=None)\n",
      "     |  \n",
      "     |  Random number generator base class used by bound module functions.\n",
      "     |  \n",
      "     |  Used to instantiate instances of Random to get generators that don't\n",
      "     |  share state.\n",
      "     |  \n",
      "     |  Class Random can also be subclassed if you want to use a different basic\n",
      "     |  generator of your own devising: in that case, override the following\n",
      "     |  methods:  random(), seed(), getstate(), and setstate().\n",
      "     |  Optionally, implement a getrandbits() method so that randrange()\n",
      "     |  can cover arbitrarily large ranges.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      Random\n",
      "     |      _random.Random\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __getstate__(self)\n",
      "     |      # Issue 17489: Since __reduce__ was defined to fix #759889 this is no\n",
      "     |      # longer called; we leave it here because it has been here since random was\n",
      "     |      # rewritten back in 2001 and why risk breaking something.\n",
      "     |  \n",
      "     |  __init__(self, x=None)\n",
      "     |      Initialize an instance.\n",
      "     |      \n",
      "     |      Optional argument x controls seeding, as for Random.seed().\n",
      "     |  \n",
      "     |  __reduce__(self)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __setstate__(self, state)\n",
      "     |  \n",
      "     |  betavariate(self, alpha, beta)\n",
      "     |      Beta distribution.\n",
      "     |      \n",
      "     |      Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "     |      Returned values range between 0 and 1.\n",
      "     |  \n",
      "     |  choice(self, seq)\n",
      "     |      Choose a random element from a non-empty sequence.\n",
      "     |  \n",
      "     |  choices(self, population, weights=None, *, cum_weights=None, k=1)\n",
      "     |      Return a k sized list of population elements chosen with replacement.\n",
      "     |      \n",
      "     |      If the relative weights or cumulative weights are not specified,\n",
      "     |      the selections are made with equal probability.\n",
      "     |  \n",
      "     |  expovariate(self, lambd)\n",
      "     |      Exponential distribution.\n",
      "     |      \n",
      "     |      lambd is 1.0 divided by the desired mean.  It should be\n",
      "     |      nonzero.  (The parameter would be called \"lambda\", but that is\n",
      "     |      a reserved word in Python.)  Returned values range from 0 to\n",
      "     |      positive infinity if lambd is positive, and from negative\n",
      "     |      infinity to 0 if lambd is negative.\n",
      "     |  \n",
      "     |  gammavariate(self, alpha, beta)\n",
      "     |      Gamma distribution.  Not the gamma function!\n",
      "     |      \n",
      "     |      Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "     |      \n",
      "     |      The probability distribution function is:\n",
      "     |      \n",
      "     |                  x ** (alpha - 1) * math.exp(-x / beta)\n",
      "     |        pdf(x) =  --------------------------------------\n",
      "     |                    math.gamma(alpha) * beta ** alpha\n",
      "     |  \n",
      "     |  gauss(self, mu, sigma)\n",
      "     |      Gaussian distribution.\n",
      "     |      \n",
      "     |      mu is the mean, and sigma is the standard deviation.  This is\n",
      "     |      slightly faster than the normalvariate() function.\n",
      "     |      \n",
      "     |      Not thread-safe without a lock around calls.\n",
      "     |  \n",
      "     |  getstate(self)\n",
      "     |      Return internal state; can be passed to setstate() later.\n",
      "     |  \n",
      "     |  lognormvariate(self, mu, sigma)\n",
      "     |      Log normal distribution.\n",
      "     |      \n",
      "     |      If you take the natural logarithm of this distribution, you'll get a\n",
      "     |      normal distribution with mean mu and standard deviation sigma.\n",
      "     |      mu can have any value, and sigma must be greater than zero.\n",
      "     |  \n",
      "     |  normalvariate(self, mu, sigma)\n",
      "     |      Normal distribution.\n",
      "     |      \n",
      "     |      mu is the mean, and sigma is the standard deviation.\n",
      "     |  \n",
      "     |  paretovariate(self, alpha)\n",
      "     |      Pareto distribution.  alpha is the shape parameter.\n",
      "     |  \n",
      "     |  randint(self, a, b)\n",
      "     |      Return random integer in range [a, b], including both end points.\n",
      "     |  \n",
      "     |  randrange(self, start, stop=None, step=1, _int=<class 'int'>)\n",
      "     |      Choose a random item from range(start, stop[, step]).\n",
      "     |      \n",
      "     |      This fixes the problem with randint() which includes the\n",
      "     |      endpoint; in Python this is usually not what you want.\n",
      "     |  \n",
      "     |  sample(self, population, k)\n",
      "     |      Chooses k unique random elements from a population sequence or set.\n",
      "     |      \n",
      "     |      Returns a new list containing elements from the population while\n",
      "     |      leaving the original population unchanged.  The resulting list is\n",
      "     |      in selection order so that all sub-slices will also be valid random\n",
      "     |      samples.  This allows raffle winners (the sample) to be partitioned\n",
      "     |      into grand prize and second place winners (the subslices).\n",
      "     |      \n",
      "     |      Members of the population need not be hashable or unique.  If the\n",
      "     |      population contains repeats, then each occurrence is a possible\n",
      "     |      selection in the sample.\n",
      "     |      \n",
      "     |      To choose a sample in a range of integers, use range as an argument.\n",
      "     |      This is especially fast and space efficient for sampling from a\n",
      "     |      large population:   sample(range(10000000), 60)\n",
      "     |  \n",
      "     |  seed(self, a=None, version=2)\n",
      "     |      Initialize internal state from hashable object.\n",
      "     |      \n",
      "     |      None or no argument seeds from current time or from an operating\n",
      "     |      system specific randomness source if available.\n",
      "     |      \n",
      "     |      If *a* is an int, all bits are used.\n",
      "     |      \n",
      "     |      For version 2 (the default), all of the bits are used if *a* is a str,\n",
      "     |      bytes, or bytearray.  For version 1 (provided for reproducing random\n",
      "     |      sequences from older versions of Python), the algorithm for str and\n",
      "     |      bytes generates a narrower range of seeds.\n",
      "     |  \n",
      "     |  setstate(self, state)\n",
      "     |      Restore internal state from object returned by getstate().\n",
      "     |  \n",
      "     |  shuffle(self, x, random=None)\n",
      "     |      Shuffle list x in place, and return None.\n",
      "     |      \n",
      "     |      Optional argument random is a 0-argument function returning a\n",
      "     |      random float in [0.0, 1.0); if it is the default None, the\n",
      "     |      standard random.random will be used.\n",
      "     |  \n",
      "     |  triangular(self, low=0.0, high=1.0, mode=None)\n",
      "     |      Triangular distribution.\n",
      "     |      \n",
      "     |      Continuous distribution bounded by given lower and upper limits,\n",
      "     |      and having a given mode value in-between.\n",
      "     |      \n",
      "     |      http://en.wikipedia.org/wiki/Triangular_distribution\n",
      "     |  \n",
      "     |  uniform(self, a, b)\n",
      "     |      Get a random number in the range [a, b) or [a, b] depending on rounding.\n",
      "     |  \n",
      "     |  vonmisesvariate(self, mu, kappa)\n",
      "     |      Circular data distribution.\n",
      "     |      \n",
      "     |      mu is the mean angle, expressed in radians between 0 and 2*pi, and\n",
      "     |      kappa is the concentration parameter, which must be greater than or\n",
      "     |      equal to zero.  If kappa is equal to zero, this distribution reduces\n",
      "     |      to a uniform random angle over the range 0 to 2*pi.\n",
      "     |  \n",
      "     |  weibullvariate(self, alpha, beta)\n",
      "     |      Weibull distribution.\n",
      "     |      \n",
      "     |      alpha is the scale parameter and beta is the shape parameter.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods defined here:\n",
      "     |  \n",
      "     |  __init_subclass__(**kwargs) from builtins.type\n",
      "     |      Control how subclasses generate random integers.\n",
      "     |      \n",
      "     |      The algorithm a subclass can use depends on the random() and/or\n",
      "     |      getrandbits() implementation available to it and determines\n",
      "     |      whether it can generate random integers from arbitrarily large\n",
      "     |      ranges.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  __dict__\n",
      "     |      dictionary for instance variables (if defined)\n",
      "     |  \n",
      "     |  __weakref__\n",
      "     |      list of weak references to the object (if defined)\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  VERSION = 3\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from _random.Random:\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  getrandbits(self, k, /)\n",
      "     |      getrandbits(k) -> x.  Generates an int with k random bits.\n",
      "     |  \n",
      "     |  random(self, /)\n",
      "     |      random() -> x in the interval [0, 1).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods inherited from _random.Random:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "    \n",
      "    class SystemRandom(Random)\n",
      "     |  SystemRandom(x=None)\n",
      "     |  \n",
      "     |  Alternate random number generator using sources provided\n",
      "     |  by the operating system (such as /dev/urandom on Unix or\n",
      "     |  CryptGenRandom on Windows).\n",
      "     |  \n",
      "     |   Not available on all systems (see os.urandom() for details).\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      SystemRandom\n",
      "     |      Random\n",
      "     |      _random.Random\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  getrandbits(self, k)\n",
      "     |      getrandbits(k) -> x.  Generates an int with k random bits.\n",
      "     |  \n",
      "     |  getstate = _notimplemented(self, *args, **kwds)\n",
      "     |  \n",
      "     |  random(self)\n",
      "     |      Get the next random number in the range [0.0, 1.0).\n",
      "     |  \n",
      "     |  seed(self, *args, **kwds)\n",
      "     |      Stub method.  Not used for a system random number generator.\n",
      "     |  \n",
      "     |  setstate = _notimplemented(self, *args, **kwds)\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from Random:\n",
      "     |  \n",
      "     |  __getstate__(self)\n",
      "     |      # Issue 17489: Since __reduce__ was defined to fix #759889 this is no\n",
      "     |      # longer called; we leave it here because it has been here since random was\n",
      "     |      # rewritten back in 2001 and why risk breaking something.\n",
      "     |  \n",
      "     |  __init__(self, x=None)\n",
      "     |      Initialize an instance.\n",
      "     |      \n",
      "     |      Optional argument x controls seeding, as for Random.seed().\n",
      "     |  \n",
      "     |  __reduce__(self)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __setstate__(self, state)\n",
      "     |  \n",
      "     |  betavariate(self, alpha, beta)\n",
      "     |      Beta distribution.\n",
      "     |      \n",
      "     |      Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "     |      Returned values range between 0 and 1.\n",
      "     |  \n",
      "     |  choice(self, seq)\n",
      "     |      Choose a random element from a non-empty sequence.\n",
      "     |  \n",
      "     |  choices(self, population, weights=None, *, cum_weights=None, k=1)\n",
      "     |      Return a k sized list of population elements chosen with replacement.\n",
      "     |      \n",
      "     |      If the relative weights or cumulative weights are not specified,\n",
      "     |      the selections are made with equal probability.\n",
      "     |  \n",
      "     |  expovariate(self, lambd)\n",
      "     |      Exponential distribution.\n",
      "     |      \n",
      "     |      lambd is 1.0 divided by the desired mean.  It should be\n",
      "     |      nonzero.  (The parameter would be called \"lambda\", but that is\n",
      "     |      a reserved word in Python.)  Returned values range from 0 to\n",
      "     |      positive infinity if lambd is positive, and from negative\n",
      "     |      infinity to 0 if lambd is negative.\n",
      "     |  \n",
      "     |  gammavariate(self, alpha, beta)\n",
      "     |      Gamma distribution.  Not the gamma function!\n",
      "     |      \n",
      "     |      Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "     |      \n",
      "     |      The probability distribution function is:\n",
      "     |      \n",
      "     |                  x ** (alpha - 1) * math.exp(-x / beta)\n",
      "     |        pdf(x) =  --------------------------------------\n",
      "     |                    math.gamma(alpha) * beta ** alpha\n",
      "     |  \n",
      "     |  gauss(self, mu, sigma)\n",
      "     |      Gaussian distribution.\n",
      "     |      \n",
      "     |      mu is the mean, and sigma is the standard deviation.  This is\n",
      "     |      slightly faster than the normalvariate() function.\n",
      "     |      \n",
      "     |      Not thread-safe without a lock around calls.\n",
      "     |  \n",
      "     |  lognormvariate(self, mu, sigma)\n",
      "     |      Log normal distribution.\n",
      "     |      \n",
      "     |      If you take the natural logarithm of this distribution, you'll get a\n",
      "     |      normal distribution with mean mu and standard deviation sigma.\n",
      "     |      mu can have any value, and sigma must be greater than zero.\n",
      "     |  \n",
      "     |  normalvariate(self, mu, sigma)\n",
      "     |      Normal distribution.\n",
      "     |      \n",
      "     |      mu is the mean, and sigma is the standard deviation.\n",
      "     |  \n",
      "     |  paretovariate(self, alpha)\n",
      "     |      Pareto distribution.  alpha is the shape parameter.\n",
      "     |  \n",
      "     |  randint(self, a, b)\n",
      "     |      Return random integer in range [a, b], including both end points.\n",
      "     |  \n",
      "     |  randrange(self, start, stop=None, step=1, _int=<class 'int'>)\n",
      "     |      Choose a random item from range(start, stop[, step]).\n",
      "     |      \n",
      "     |      This fixes the problem with randint() which includes the\n",
      "     |      endpoint; in Python this is usually not what you want.\n",
      "     |  \n",
      "     |  sample(self, population, k)\n",
      "     |      Chooses k unique random elements from a population sequence or set.\n",
      "     |      \n",
      "     |      Returns a new list containing elements from the population while\n",
      "     |      leaving the original population unchanged.  The resulting list is\n",
      "     |      in selection order so that all sub-slices will also be valid random\n",
      "     |      samples.  This allows raffle winners (the sample) to be partitioned\n",
      "     |      into grand prize and second place winners (the subslices).\n",
      "     |      \n",
      "     |      Members of the population need not be hashable or unique.  If the\n",
      "     |      population contains repeats, then each occurrence is a possible\n",
      "     |      selection in the sample.\n",
      "     |      \n",
      "     |      To choose a sample in a range of integers, use range as an argument.\n",
      "     |      This is especially fast and space efficient for sampling from a\n",
      "     |      large population:   sample(range(10000000), 60)\n",
      "     |  \n",
      "     |  shuffle(self, x, random=None)\n",
      "     |      Shuffle list x in place, and return None.\n",
      "     |      \n",
      "     |      Optional argument random is a 0-argument function returning a\n",
      "     |      random float in [0.0, 1.0); if it is the default None, the\n",
      "     |      standard random.random will be used.\n",
      "     |  \n",
      "     |  triangular(self, low=0.0, high=1.0, mode=None)\n",
      "     |      Triangular distribution.\n",
      "     |      \n",
      "     |      Continuous distribution bounded by given lower and upper limits,\n",
      "     |      and having a given mode value in-between.\n",
      "     |      \n",
      "     |      http://en.wikipedia.org/wiki/Triangular_distribution\n",
      "     |  \n",
      "     |  uniform(self, a, b)\n",
      "     |      Get a random number in the range [a, b) or [a, b] depending on rounding.\n",
      "     |  \n",
      "     |  vonmisesvariate(self, mu, kappa)\n",
      "     |      Circular data distribution.\n",
      "     |      \n",
      "     |      mu is the mean angle, expressed in radians between 0 and 2*pi, and\n",
      "     |      kappa is the concentration parameter, which must be greater than or\n",
      "     |      equal to zero.  If kappa is equal to zero, this distribution reduces\n",
      "     |      to a uniform random angle over the range 0 to 2*pi.\n",
      "     |  \n",
      "     |  weibullvariate(self, alpha, beta)\n",
      "     |      Weibull distribution.\n",
      "     |      \n",
      "     |      alpha is the scale parameter and beta is the shape parameter.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods inherited from Random:\n",
      "     |  \n",
      "     |  __init_subclass__(**kwargs) from builtins.type\n",
      "     |      Control how subclasses generate random integers.\n",
      "     |      \n",
      "     |      The algorithm a subclass can use depends on the random() and/or\n",
      "     |      getrandbits() implementation available to it and determines\n",
      "     |      whether it can generate random integers from arbitrarily large\n",
      "     |      ranges.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors inherited from Random:\n",
      "     |  \n",
      "     |  __dict__\n",
      "     |      dictionary for instance variables (if defined)\n",
      "     |  \n",
      "     |  __weakref__\n",
      "     |      list of weak references to the object (if defined)\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes inherited from Random:\n",
      "     |  \n",
      "     |  VERSION = 3\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from _random.Random:\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods inherited from _random.Random:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "\n",
      "FUNCTIONS\n",
      "    betavariate(alpha, beta) method of Random instance\n",
      "        Beta distribution.\n",
      "        \n",
      "        Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "        Returned values range between 0 and 1.\n",
      "    \n",
      "    choice(seq) method of Random instance\n",
      "        Choose a random element from a non-empty sequence.\n",
      "    \n",
      "    choices(population, weights=None, *, cum_weights=None, k=1) method of Random instance\n",
      "        Return a k sized list of population elements chosen with replacement.\n",
      "        \n",
      "        If the relative weights or cumulative weights are not specified,\n",
      "        the selections are made with equal probability.\n",
      "    \n",
      "    expovariate(lambd) method of Random instance\n",
      "        Exponential distribution.\n",
      "        \n",
      "        lambd is 1.0 divided by the desired mean.  It should be\n",
      "        nonzero.  (The parameter would be called \"lambda\", but that is\n",
      "        a reserved word in Python.)  Returned values range from 0 to\n",
      "        positive infinity if lambd is positive, and from negative\n",
      "        infinity to 0 if lambd is negative.\n",
      "    \n",
      "    gammavariate(alpha, beta) method of Random instance\n",
      "        Gamma distribution.  Not the gamma function!\n",
      "        \n",
      "        Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "        \n",
      "        The probability distribution function is:\n",
      "        \n",
      "                    x ** (alpha - 1) * math.exp(-x / beta)\n",
      "          pdf(x) =  --------------------------------------\n",
      "                      math.gamma(alpha) * beta ** alpha\n",
      "    \n",
      "    gauss(mu, sigma) method of Random instance\n",
      "        Gaussian distribution.\n",
      "        \n",
      "        mu is the mean, and sigma is the standard deviation.  This is\n",
      "        slightly faster than the normalvariate() function.\n",
      "        \n",
      "        Not thread-safe without a lock around calls.\n",
      "    \n",
      "    getrandbits(k, /) method of Random instance\n",
      "        getrandbits(k) -> x.  Generates an int with k random bits.\n",
      "    \n",
      "    getstate() method of Random instance\n",
      "        Return internal state; can be passed to setstate() later.\n",
      "    \n",
      "    lognormvariate(mu, sigma) method of Random instance\n",
      "        Log normal distribution.\n",
      "        \n",
      "        If you take the natural logarithm of this distribution, you'll get a\n",
      "        normal distribution with mean mu and standard deviation sigma.\n",
      "        mu can have any value, and sigma must be greater than zero.\n",
      "    \n",
      "    normalvariate(mu, sigma) method of Random instance\n",
      "        Normal distribution.\n",
      "        \n",
      "        mu is the mean, and sigma is the standard deviation.\n",
      "    \n",
      "    paretovariate(alpha) method of Random instance\n",
      "        Pareto distribution.  alpha is the shape parameter.\n",
      "    \n",
      "    randint(a, b) method of Random instance\n",
      "        Return random integer in range [a, b], including both end points.\n",
      "    \n",
      "    random() method of Random instance\n",
      "        random() -> x in the interval [0, 1).\n",
      "    \n",
      "    randrange(start, stop=None, step=1, _int=<class 'int'>) method of Random instance\n",
      "        Choose a random item from range(start, stop[, step]).\n",
      "        \n",
      "        This fixes the problem with randint() which includes the\n",
      "        endpoint; in Python this is usually not what you want.\n",
      "    \n",
      "    sample(population, k) method of Random instance\n",
      "        Chooses k unique random elements from a population sequence or set.\n",
      "        \n",
      "        Returns a new list containing elements from the population while\n",
      "        leaving the original population unchanged.  The resulting list is\n",
      "        in selection order so that all sub-slices will also be valid random\n",
      "        samples.  This allows raffle winners (the sample) to be partitioned\n",
      "        into grand prize and second place winners (the subslices).\n",
      "        \n",
      "        Members of the population need not be hashable or unique.  If the\n",
      "        population contains repeats, then each occurrence is a possible\n",
      "        selection in the sample.\n",
      "        \n",
      "        To choose a sample in a range of integers, use range as an argument.\n",
      "        This is especially fast and space efficient for sampling from a\n",
      "        large population:   sample(range(10000000), 60)\n",
      "    \n",
      "    seed(a=None, version=2) method of Random instance\n",
      "        Initialize internal state from hashable object.\n",
      "        \n",
      "        None or no argument seeds from current time or from an operating\n",
      "        system specific randomness source if available.\n",
      "        \n",
      "        If *a* is an int, all bits are used.\n",
      "        \n",
      "        For version 2 (the default), all of the bits are used if *a* is a str,\n",
      "        bytes, or bytearray.  For version 1 (provided for reproducing random\n",
      "        sequences from older versions of Python), the algorithm for str and\n",
      "        bytes generates a narrower range of seeds.\n",
      "    \n",
      "    setstate(state) method of Random instance\n",
      "        Restore internal state from object returned by getstate().\n",
      "    \n",
      "    shuffle(x, random=None) method of Random instance\n",
      "        Shuffle list x in place, and return None.\n",
      "        \n",
      "        Optional argument random is a 0-argument function returning a\n",
      "        random float in [0.0, 1.0); if it is the default None, the\n",
      "        standard random.random will be used.\n",
      "    \n",
      "    triangular(low=0.0, high=1.0, mode=None) method of Random instance\n",
      "        Triangular distribution.\n",
      "        \n",
      "        Continuous distribution bounded by given lower and upper limits,\n",
      "        and having a given mode value in-between.\n",
      "        \n",
      "        http://en.wikipedia.org/wiki/Triangular_distribution\n",
      "    \n",
      "    uniform(a, b) method of Random instance\n",
      "        Get a random number in the range [a, b) or [a, b] depending on rounding.\n",
      "    \n",
      "    vonmisesvariate(mu, kappa) method of Random instance\n",
      "        Circular data distribution.\n",
      "        \n",
      "        mu is the mean angle, expressed in radians between 0 and 2*pi, and\n",
      "        kappa is the concentration parameter, which must be greater than or\n",
      "        equal to zero.  If kappa is equal to zero, this distribution reduces\n",
      "        to a uniform random angle over the range 0 to 2*pi.\n",
      "    \n",
      "    weibullvariate(alpha, beta) method of Random instance\n",
      "        Weibull distribution.\n",
      "        \n",
      "        alpha is the scale parameter and beta is the shape parameter.\n",
      "\n",
      "DATA\n",
      "    __all__ = ['Random', 'seed', 'random', 'uniform', 'randint', 'choice',...\n",
      "\n",
      "FILE\n",
      "    c:\\program files\\anaconda3\\lib\\random.py\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import random # random 随机函数\n",
    "help(random)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "8c15282a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9723054306788579"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.random() #范围在0-1之间随机出一个浮点值即小数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "02b90a2d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(1,6)#(1,6)相当于在1-6区间范围内随机得出一个值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "55840d00",
   "metadata": {},
   "source": [
    "#### for 循环配合内置函数range()的使用\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "5944fabc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This second seems a little odd.\n",
      "This second seems a little odd.\n",
      "Not an odd second.\n",
      "This second seems a little odd.\n",
      "This second seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "# 课本案例\n",
    "from datetime import datetime\n",
    "import random\n",
    "import time\n",
    "\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,57,59]\n",
    "\n",
    "# range 其实决定了for循环执行的次数\n",
    "for i in range(5):\n",
    "    right_this_second = datetime.today().second\n",
    "    if right_this_second in odds:\n",
    "        print(\"This second seems a little odd.\")\n",
    "    else:  #额外注意缩进（后续会讲到）\n",
    "         print(\"Not an odd second.\")\n",
    "    wait_time = random.randint(1,5)\n",
    "    time.sleep(wait_time)# 每个命令执行之间因为有 wait_time 所以有等待时间\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "ef2fa9a2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "该时间为秒为单位的奇数时间 ---当前时间节点的秒钟： 47\n",
      "等待的随机时间： 5\n",
      "Not an odd second. ---当前时间节点的秒钟： 52\n",
      "等待的随机时间： 7\n",
      "该时间为秒为单位的奇数时间 ---当前时间节点的秒钟： 59\n",
      "等待的随机时间： 3\n",
      "Not an odd second. ---当前时间节点的秒钟： 2\n",
      "等待的随机时间： 2\n",
      "Not an odd second. ---当前时间节点的秒钟： 4\n",
      "等待的随机时间： 8\n"
     ]
    }
   ],
   "source": [
    "# 改进\n",
    "from datetime import datetime\n",
    "import random\n",
    "import time\n",
    "\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,57,59]\n",
    "\n",
    "for i in range(5):\n",
    "    right_this_second = datetime.today().second\n",
    "    if right_this_second in odds:\n",
    "        print(\"该时间为秒为单位的奇数时间\",\"---当前时间节点的秒钟：\",right_this_second)\n",
    "    else: \n",
    "         print(\"Not an odd second.\",\"---当前时间节点的秒钟：\",right_this_second)\n",
    "    wait_time = random.randint(1,10)\n",
    "    print(\"等待的随机时间：\",wait_time)\n",
    "    time.sleep(wait_time)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "454c2ed2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cat\n",
      "dog\n",
      "rabbit\n"
     ]
    }
   ],
   "source": [
    "# 拓展\n",
    "name = [\"cat\",\"dog\",\"rabbit\"]\n",
    "for i in name:\n",
    "    print(i)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "0ad717a6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cat---2021000001---2021000001\n",
      "dog---2021000002---2021000002\n",
      "rabbit---2021000003---2021000003\n"
     ]
    }
   ],
   "source": [
    "names = ['cat---2021000001','dog---2021000002','rabbit---2021000003']   #enumerate 枚举 产生steps的位置索引值（index）\n",
    "for k,i in enumerate(names):                                        #for i in names: 取到了names中的值（values）\n",
    "    print(i+\"---\"+str(2021000000+k+1))                               # for 遍历数据的重要操作\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a570cc08",
   "metadata": {},
   "source": [
    "(①=② ①是变量 等号是赋值 赋的就是②那一堆)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b826ede0",
   "metadata": {},
   "source": [
    "单引号或者双引号又或者三引号括起来的就是字符串。不管括起来的是什么语言，如果引号里面又是引号，我们可以用“/”或者外面是双引号里面是单引号。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fe8737b",
   "metadata": {},
   "source": [
    "如果字符很复杂，str是字符串的意思"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2ae971d7",
   "metadata": {},
   "source": [
    "Type检查字符串的复杂程度"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b48dfdd",
   "metadata": {},
   "source": [
    "不是看着是个数值就可以运算的，只有两个没引号的才可以运算"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "57d9743e",
   "metadata": {},
   "source": [
    "写代码，注释非常重要。\n",
    "##### 注释存在的意义\n",
    "1.记录代码笔记\n",
    "2.注释掉不想运行的代码 （多行注释也是用'''或\"\"\"包围）\n",
    "3.''' ''' 可以在python的代码中存储python代码的数据（例如HTML） 打印变量\n",
    "\n",
    "* 范例1\n",
    "被注释的内容   （这是单行注释一般用于代码的笔记）\n",
    "\n",
    "* 范例2   用'''包围不想运行的代码或者用\"\"\" 也可以\n",
    "'''\n",
    " import random\n",
    "wait_time = random.randint(1,6)\n",
    "print(wait_time)\n",
    "\n",
    "word = \"bottles\"\n",
    "print(word)\n",
    "'''\n",
    "\n",
    "\"\"\"      \n",
    "import random\n",
    "wait_time = random.randint(1,6)\n",
    "print(wait_time)\n",
    "\n",
    "word = \"bottles\"\n",
    "print(word)\n",
    "\"\"\"\n",
    "\n",
    "* 范例3  打印变量      \n",
    "下面的示例是 在开始将''' 赋值给一个变量  由于''' 可以储存代码数据 所以可以将后面的代码都储存后再print(变量) ，这样就可以打印变量。\n",
    "test1 ='''\n",
    "import random\n",
    "wait_time = random.randint(1,60)\n",
    "print(wait_time)\n",
    "\n",
    "word = \"bottles\"\n",
    "print(word)\n",
    "'''\n",
    "print(test1)   # 在结尾处打印变量"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ad7dd51a",
   "metadata": {},
   "source": [
    "datetime.Tab    程序里有的就import它 比如：import time"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8058b6c4",
   "metadata": {},
   "source": [
    "time.sleep"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb91313f",
   "metadata": {},
   "source": [
    "i是特指某：①如果range里面只有一个数字，它代表我们代码执行的数字。②有两个数字。③有三个数字。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e20de4e8",
   "metadata": {},
   "source": [
    "import调用 它后面是空格，其他后面可以是“.”，比如：import time 跟random.randint(1,36)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b97d799d",
   "metadata": {},
   "source": [
    "Print是变量"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c1cf4841",
   "metadata": {},
   "source": [
    "range(5)将和for循环一起实现for循环子代码执行的次数（5）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b4e2a65",
   "metadata": {},
   "source": [
    "enumerate 枚举 产生steps的位置索引值（index）\n",
    "for i in names:取到了names中的值（values）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9fda5329",
   "metadata": {},
   "source": [
    "for 遍历数据的重要操作\n",
    " > for i in names:\n",
    "   print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a4d691c2",
   "metadata": {},
   "source": [
    "* 格式化：isoformat\n",
    "> 如:datetime.date.isoformat(datetime.date.todayd())\n",
    " ‘2021-09-30’"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "584c9004",
   "metadata": {},
   "source": [
    "四个空格"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "944e2141",
   "metadata": {},
   "source": [
    "Range的强大功能详细一点"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2b18ded8",
   "metadata": {},
   "source": [
    "产生一系列数值的方法，通常跟for循环一起使用，决定for循环的次数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d72e44b2",
   "metadata": {},
   "source": [
    "右边数减左边数 如：list(range(1,6)） ☞[1, 2, 3, 4, 5]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d6eca2b7",
   "metadata": {},
   "source": [
    "Help只能看模块，看str的地方，也可以看数值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "923e6aa3",
   "metadata": {},
   "source": [
    "* 变量名i\n",
    "> 由print（i)这件案例中我们明白了，在循环过程中，变量名虽然没变，但值是动态变化的，也就意味着所有的for循环的变量值都在随着循环次数的改变而可能发生变化"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ebb9cc8a",
   "metadata": {},
   "source": [
    " 有空可以去python官网试试\n",
    "\n",
    "课程表：准备odds数据判断在不在当前时间 当前的时间 课表 最后print该上什么课"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60e6af62",
   "metadata": {},
   "source": [
    "def是print定义方式的函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9b54d797",
   "metadata": {},
   "source": [
    " 三个点是支持字符串换行的，两个点不支持"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "781504dc",
   "metadata": {},
   "source": [
    "* 占位符有顺序！要依次填入\n",
    "> 如果有很多位置，一个HTML页面有很多数据来占用位置，对顺序要求太苛刻了，容易出错。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b7d133e8",
   "metadata": {},
   "source": [
    "format()是一个字符串的格式化方法/函数 优化 占位符\n",
    "\n",
    "优势：①不需要考虑参数出现的顺序 ②多个重复项只需要赋值一次（明确数据输入(如：变量age）)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "54240289",
   "metadata": {},
   "source": [
    " 在从左到右取值，右边的值取不到。左边第一个值为0（可看为左边正数，右边负数）☞0123\n",
    "                                                                              -4-3-2-1\n",
    "                                                                              -4-3-2-101234\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8e8edff",
   "metadata": {},
   "source": [
    "gitee中文 github英文 github比较好用，但挺多人用gitee。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "73b08d07",
   "metadata": {},
   "source": [
    "###### 任何代码组都可以包含任意个嵌套代码组，它们也必须缩进。python程序员谈到嵌入代码组时，通常会谈到缩进层次。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6f2efa12",
   "metadata": {},
   "source": [
    "用户输入\n",
    "数据中的用户信息\n",
    "user_data = \"110\"\n",
    "password_data = \"123456\"\n",
    "\n",
    "\n",
    "##### while True 使用案例\n",
    "> 1.可以实现 for循环 + range函数的功能\n",
    "> 2.可给定特定的条件（比如说 账号和密码都相等）跳出 （死循环）\n",
    "* 用以下范例\n",
    "\"\"\"\n",
    "count= 0  # count 指的是次数\n",
    "while True:   #如果出现错误的话，还可以继续循环\n",
    "    count = count+1\n",
    "    print(\"ring,ring,ring,The phone is ringing now\",\"count=\",count)  #所有在打印的括号中的字符串（文本）都要用\"\"包起来，变量除外\n",
    "    if count == 10:\n",
    "        break  # 结束该循环\n",
    "\"\"\"\n",
    "\n",
    "##### 判断 数据库中的用户信息 =？ 用户登录输入的信息\n",
    "\n",
    "####   考虑到产品需求\n",
    "1.如果成功输入，账号密码，显示登录成功，欢迎 用户的名字 使用\n",
    "2.如果输入失败，让用户重新输入，并显示 账号或密码输入错误 还有3次可以尝试的机会\n",
    "3.如果3次机会都用掉，5分钟后在尝试登录\n",
    "\n",
    "#### 缩进可以看出代码的条件是否为同一级别的  相同级别的条件所在行的缩进是一致的\n",
    "\n",
    "count = 3  # 限制用户只有三次机会，则该代码只会自动重复出现3次输入端\n",
    "while True:\n",
    "    #count 自减1 ：count- =1\n",
    "    count -=1    # count等于3 ，count-等于1（表示1赋值给了变量count-）\n",
    "    if count == -1:\n",
    "        print(\"请在5分钟后再尝试\")\n",
    "    #用户登录输入的信息\n",
    "    else:\n",
    "        username = input(\"请输入正确的账号：\")\n",
    "        password = input(\"请输入正确的密码：\")\n",
    "        # 判断账号是否正确\n",
    "        # 1.账号正确\n",
    "    if username == user_data:\n",
    "        # 判断 密码是否正确\n",
    "        #a.密码正确\n",
    "        if password == password_data:\n",
    "            print(\"登录成功，欢迎\",user_data,\"使用\")\n",
    "            break  #在这里插入break是因为只要循环到用户输入正确的账号密码并登录成功后就结束了\n",
    "        #b.密码不正确\n",
    "        else:\n",
    "            print(\"账号或密码输入错误！，请重新输入，您还有：\",count,\"次尝试的机会\")\n",
    "        # 2.账号不正确\n",
    "    else:\n",
    "        print(\"账号或密码输入错误！请重新输入，您还有：\",count,\"次尝试的机会\")\n",
    "\n",
    "\n",
    "##### 补充：占位符：%s"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f89c162",
   "metadata": {},
   "source": [
    "占位符是有顺序的 \n",
    "占位符的优势：如果有几百个需要填进去的内容？容易顺序乱掉，出现打印结果的不正确🔜这是百分号s占位符容易出现的错误"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a719086f",
   "metadata": {},
   "source": [
    "list：列表是有顺序的，所以可以用index去取值\n",
    "\n",
    "两个列表相加顺序是不变的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f43bf1d2",
   "metadata": {},
   "source": [
    "切片slice：\n",
    "右边的值取不到 例如（0，3）索引为3的值取不到。\n",
    "当从0开始取值时，0可以忽略不写。如：list{：3}。可以倒着来取值，可以从左往右取值：也可以从右往左取值，index和slice都可以，两边都取得到。不管往哪边取值，右边的值都取不到。而且不能改变方向，比如错误的写法{-3，0}，这样就是取值为空，说明slice写错了。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "265acf9e",
   "metadata": {},
   "source": [
    "列表的基本特征：方括号 里面可以是数值可以去字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60656713",
   "metadata": {},
   "source": [
    "两个列表的顺序可以相加的，而且还能做乘法运算"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d76dc846",
   "metadata": {},
   "source": [
    "步长，List列表slice：[start:stop:step]\n",
    "```\n",
    "如果没有指定开始值，则默认为0；\n",
    "如果没有指定结束值，则取列表允许的最大值；\n",
    "如果没有指定步长值，则默认步长为1.\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2fae14c1",
   "metadata": {},
   "source": [
    "#### 列表list\n",
    "#### 构建列表 形式[] 其中元素以\" , \"隔开    列表也是一个变量\n",
    "#### 列表是有顺序的一组值，顺序是从0位置开始\n",
    "#### 相关学习文档在：https://docs.python.org/3/tutorial/introduction.html#lists\n",
    "\n",
    "names_str = [\"A\",\"B\",\"C\",\"D\",\"E\"]\n",
    "print(names_str)\n",
    "\n",
    "#### 应用1：取值（从列表中取出字母）  从0开始取 各个字母所对应的位置数：A-0 B-1 C-2 D-3 E-4\n",
    "print(names_str[0])  # 取出列表中的第一个值\n",
    "print(names_str[4])  # 取出列表最后一个\n",
    "\n",
    "#### 应用2：一次取多个对应值\n",
    "user_name_list = [\"dog\",\"cat\",\"rabbit\"]\n",
    "password_list = [110,120,119]\n",
    "user_data_list = [\"D\",\"C\",\"R\"]\n",
    "usrr_age_list = [1,2,3]\n",
    "####  ......  还可以添加多个list\n",
    "\n",
    "print(user_name_list[0])  # 一次取出每个列表中的第一个值\n",
    "print(password_list[0])\n",
    "print(user_data_list[0])\n",
    "print(usrr_age_list[0])\n",
    "#### ......  同理也可以打印出多个\n",
    "\n",
    "### 列表嵌套一\n",
    "info_list = [[\"dog\",110,\"D\"],[\"cat\",120,\"C\"],[\"rabbit\",119,\"R\"]]\n",
    "print(info_list[1])   #  所得的值为['cat', 120, 'C']\n",
    "### 列表嵌套二\n",
    "a = [\"a\",\"b\",\"c\"]\n",
    "b = [\"1\",\"2\",\"3\"]\n",
    "x = [a,b]\n",
    "print(x)\n",
    "print(x[1])  # 得 [1,2,3]\n",
    "print(x[0][1])  # 结果为b ,因为先在x中取出列表a[a,b,c]，再从列表a中取出位置数为1的值 b\n",
    "\n",
    "### 数据结构之列表的切片\n",
    "### 切片的查询\n",
    "    # -4,-3,-2,-1,0,1,2,3 (只有正数才有0，而负数没有可以理解为在python中每个变量只能用一次，不能重复)\n",
    "    # slices(切片)数值是指值（values）在list列表中的位置\n",
    "names = [\"A\",\"B\",\"C\",\"D\"]\n",
    "### 取值有两种方法 单索引（单个值）  和  slice切片（多个或者单个值）\n",
    "### 1. 正数即正向取值 从左到右\n",
    "### 每个字符串所对应的位置数：A-0；B-1；C-2；D-3\n",
    "print(names[2])  # 所取出的值为C\n",
    "### 2. 负数即方向取值 从右到左\n",
    "### 每个字符串所对应的位置数：A—— -4 ; B—— -3 ; C—— -2 ; D—— -1\n",
    "print(names[-3])   # 所取出的值为B\n",
    "### 3.特殊\n",
    "#### print(names[4]) # IndexError: list index out of range  所取的值不在列表范围内所以取不到 所以会报错\n",
    "\n",
    "### 补充列表的单索引用法：与切片的规则一致\n",
    "* 1.列表中的所有元素都有编号——从0开始递增\n",
    "* 2.索引只一次只能取出一个值相对于列表来说\n",
    "* 3.注意区分单索引索引和index() 函数的概念\n",
    "list = [\"A\",\"B\",\"C\"]\n",
    "print(list[1])\n",
    "\n",
    "### 切片的另一种写法\n",
    "names = [\"A\",\"B\",\"C\",\"D\"]\n",
    "#### 1. 取所有的值\n",
    "print(names[:]) # 若要从0开始取值 可以不用写0，python默认0开始取值\n",
    "#### 2. 正数（正向取值） 从左往右取值时，右边的值取不到\n",
    "print(names[1:3])\n",
    "### 3. 负数（方向取值） 从右往左取值时，右边的值取不到 且从取的数值位置大小来看 ，更大的值要放在右侧（-4：-2）\n",
    "print(names[-3:-1])\n",
    "### 4.若右侧不写任何值则可以取到右侧的值 最后一个值一定不能写0\n",
    "print(names[2:])\n",
    "print(names[-4:])\n",
    "\n",
    "### 5. 特殊 可以指定 slice切片的步长 step\n",
    "num_list = list(range(10))\n",
    "print(num_list)\n",
    "print(num_list[2:9:3]) # print(num_list[起始值：结束值：步长]  默认值为[0：表中的最大值：1]\n",
    "##### 所得结果为[0,1,2,3,4,5,6,7,8,9]\n",
    "##### 所得的值为 2，5，8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2098cb95",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(names[:])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b012336c",
   "metadata": {},
   "source": [
    "###### 1.在从左往右取值时，右边的值取不到\n",
    "> print(names[1:3])\n",
    "######  如果从0开始取值，0可省略不写\n",
    "> print(names[:3])\n",
    "\n",
    "###### 2.在从右往左取值时，右边的值取不到\n",
    "> print(name[-3:-1])\n",
    "\n",
    "###### 怎么能取到 -1这个位置的值呢？右侧不写任何值\n",
    "print(names[-3:])\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e45b5cb6",
   "metadata": {},
   "source": [
    "if today == 'saturday':\n",
    "    print('Party!!')\n",
    "elif today == 'Sunday':\n",
    "    print('Recover.')\n",
    "else:\n",
    "    print('work,work,work.')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6611c8b1",
   "metadata": {},
   "source": [
    "3个单独的代码组：一个对应“if”，另一个对应“elif”，最后一个对应“else”（接受所有其他条件）\n",
    "> 而且else后面一定要有冒号！！！"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d7524393",
   "metadata": {},
   "source": [
    "在python中用缩进区分代码组"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6ca756db",
   "metadata": {},
   "source": [
    "补充用户信息 ：打印 （print）：\n",
    " 当用户输入信息后 后台系统会去调后台数据库找到相对应的用户信息\n",
    "\n",
    "占位符和 .format 来模拟后台调出用户信息\n",
    "print 就意味着换行 end=/n 所以每输入一个print就会将打印的内容自动换行\n",
    "print(\"Hello word\")\n",
    "print(\"I like python\")\n",
    "\n",
    "当你想查看某个变量或是某个代码时 可以将鼠标停留在变量或代码处 即可查看关于该变量或者代码的相关属性和定义\n",
    "pycharm 中 颜色区分： 黑色为变量（可以对其赋任意值，是动态变化的）  绿色为字符串(是固定不变的)\n",
    "\n",
    "要求用户输入以下信息 用input\n",
    "name = input(\"name: \")\n",
    "age = input(\"age: \")\n",
    "job = input(\"job: \")\n",
    "salary = input(\"salary: \")\n",
    "\n",
    "1. 字符串拼接 +打印\n",
    "字符串是一个定量，无法动态变化。如果要使打印出的字符串能够动态变化，就需要将字符串拆开变更为多个部分，将变量穿插入其中。注意！！！记住字符串一定要用引号包起来\n",
    "\n",
    " info1 = '''-------- INFO --------''' +name+ '''--------''' + '''    \n",
    " 为了美观性 添加一行用于分割上下文 对于变量info的名称可以随意更改\n",
    " name: ''' +name+ '''    这里name是变量  这里的+是用于拼接下行的字符串  '''用于换行和包住字符串        \n",
    "age: ''' +age+ '''\n",
    "job: ''' +job+ '''\n",
    "salary: ''' +salary    因为salary（变量）后面没有需要拼接的字符串所以不用加引号\n",
    " print(info1)\n",
    "\n",
    "\n",
    " 2. 占位符\n",
    "常见的几种打印占位符格式的表示：\n",
    " %s代表 string\n",
    "%d代表 number  设置该占位符时用 int(input())\n",
    "%f代表 float（浮点即小数）\n",
    "注意点：!!!\n",
    " 占位符有顺序 必须依次填入相对应的内容 重复值也需要填入\n",
    "\n",
    "info2 = '''-------- INFO %s --------\n",
    "name: %s\n",
    "age: %s\n",
    "job: %s\n",
    "salary: %s                       \n",
    "注意！！！这里的 %s是占位符替代了变量\n",
    "'''%(name,name,age,job,salary)   在（）内的都是变量\n",
    "print(info2)\n",
    "\n",
    "如果设置要求 用户只能在特定的位置输入数值 其它位置为字符串\n",
    "在python中默认输入的都为字符串(str)  所以在使用input的时候要依据需求来改变\n",
    "input 是字符串   如果想让输出的内容为数值型 需要强制转换数据类型 用int 。\n",
    "\n",
    "name = input(\"name: \")\n",
    "age = int(input(\"age: \"))\n",
    "job = input(\"job: \")\n",
    "salary = int(input(\"salary: \"))\n",
    "\n",
    "info3 = '''-------- INFO %s --------\n",
    "name: %s\n",
    "age: %d\n",
    "job: %s\n",
    "salary: %d\n",
    "'''%(name,name,age,job,salary)\n",
    "print(info3)\n",
    "\n",
    "\n",
    "3.   .format()  是一个字符串的格式化方法/函数  这个优化了占位符  必须使用的是{}将变量包起来\n",
    "优点（与占位符相比）：1.不需要考虑参数出现的顺序 2.多个重复项只需要赋值一次  明确数据输入 （如：变量name） 和输出（如：打印的html_name）\n",
    "info4 = '''-------- INFO {html_name}--------\n",
    "name: {html_name}\n",
    "age: {html_age}\n",
    "job: {html_job}\n",
    "salary: {html_salary}\n",
    "''' .format(html_age=age,html_job=job,html_name=name,html_salary=salary)\n",
    "print(info4)\n",
    "\n",
    ".format() 的{}内也可以使用数值但数值必须在对应变量的个数范围内 （如下只有4个变量 不可以出现超过数字4的数字） 不同项的输出值对应的数值不同 （）内的变量没有顺序\n",
    "info5 =  '''-------INFO {0} -------\n",
    "Name:{0}\n",
    "Age:{1}\n",
    "Job:{3}\n",
    "Salary:{2}\n",
    "'''.format(name,salary,age,job)\n",
    "print(info5)\n",
    "\n",
    "补充关于换行  由于引号用来包字符串，同时当字符串内容很多时为了更好的换行 所以一般使用''' 三引号既起到包字符串又起到换行的作用\n",
    "print('''hello''' +name +'''word''')          \n",
    "变量  +：拼接下段   \n",
    "'''既是word字符串的引号之一又有换行作用  \n",
    "'''放在需要换行的地方 则引号之后的字符串就要另起一行开始写 （在最后再来'''把整个字符串括起来）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7731915f",
   "metadata": {},
   "source": [
    "完整的高教动态所有页面url = \"https://www.nfu.edu.cn/{新闻}/index{页码}.htm\".format(页码=str(i),新闻=\"ztb\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1cebfa49",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "尝试弄弄自动时间\n",
      "现在的时间是： 2021/10—/05 20:03 Tuesday\n"
     ]
    }
   ],
   "source": [
    "print(\"尝试弄弄自动时间\")\n",
    "import time\n",
    "now_time1 = time.strftime(\"%Y/%m—/%d\")\n",
    "now_time2 = time.strftime(\"%H:%M\")\n",
    "now_time3 = time.strftime(\"%A\")\n",
    "print(\"现在的时间是：\",now_time1,now_time2,now_time3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a5099af",
   "metadata": {},
   "source": [
    "##### 转义字符 () 表示该字符与后面相邻的一个字符共同组成了新的含义\n",
    "* \\n 表示换行\n",
    "* \\ 表示反斜杆\n",
    "* ' 表示单引号\n",
    "* '' 表示双引号\n",
    "* \\t 表示水平制表符\n",
    "* \\v 表示垂直制表符\n",
    "#### 注意在使用这些转义字符时一定要用print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "fbf9c982",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I\n",
      "love\n",
      "Python\t语言\t课程\n"
     ]
    }
   ],
   "source": [
    "print(\"I\\nlove\\nPython\\t语言\\t课程\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
